TestTimberImage::testPNGtoJPG PHP Method

testPNGtoJPG() public method

public testPNGtoJPG ( )
    function testPNGtoJPG()
    {
        if (!extension_loaded('gd')) {
            self::markTestSkipped('PNG to JPEG conversion test requires GD extension');
        }
        $file_loc = self::copyTestImage('eastern-trans.png');
        $upload_dir = wp_upload_dir();
        $new_file = TimberImageHelper::img_to_jpg($upload_dir['url'] . '/eastern-trans.png', '#FFFF00');
        $location_of_image = TimberImageHelper::get_server_location($new_file);
        $this->assertFileExists($location_of_image);
        $image = imagecreatefromjpeg($location_of_image);
        $pixel_rgb = imagecolorat($image, 1, 1);
        $colors = imagecolorsforindex($image, $pixel_rgb);
        $this->assertEquals(255, $colors['red']);
        $this->assertEquals(255, $colors['green']);
        $this->assertEquals(0, $colors['blue']);
    }