imagejpeg don't seems to work on IIS 10 + PHP

162 Views Asked by At

I've a local server running a website with IIS. When i run (move_uploaded_file($tempfile, $uploadfile)) all goes well (POST method used).

Now i wish to compress the image, here is the code:

 // Compress image
function compressImage($source, $destination, $quality) {

    $info = getimagesize($source);

    if ($info['mime'] == 'image/jpeg') {
        $image = imagecreatefromjpeg($source);
    } elseif ($info['mime'] == 'image/gif') {
        $image = imagecreatefromgif($source);
    } elseif ($info['mime'] == 'image/png') {
        $image = imagecreatefrompng($source);
    }

    imagejpeg($image, $destination, $quality);

}
$foo= compressImage($tempfile, $uploadfile, 75);

who gives me 500 error.

Should i enable some plugin on the server side? I've tried a bunch of code, it still doesn't work (i've played also with dir names.. actually they goes well with move_uploaded_file)

edit: strange thing, the $tempfile content is: C:WindowsTempphp92AF.tmp without slashes, but it works moving the file.... $uploadfile instead, is: ../../../Users/admin/Documents/uploads/2image.png

1

There are 1 best solutions below

0
On

And so.. i've figured out!

request tracing was not so useful (for me). Instead i've added those 2 small lines to my php code to log errors:

 ini_set('display_errors',1);
error_reporting(E_ALL);

The first was

Fatal error: Uncaught Error: Call to undefined function imagecreatefromjpeg() in C:\inet

Resolved with:

extension=php_gd.dll

in php.ini. Then another error about the permissions.

FYI