😕
gd-png error: compression level must be 0 through 9

The above error is displaying when the following function is called

function resizeImage($image,$width,$height,$scale)
{
$newImageWidth = ceil($width $scale);
$newImageHeight = ceil($height
$scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
$source = imagecreatefrompng($image);
imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
imagepng($newImage,$image,90);
chmod($image, 0777);
return $image;
}

after creating the new re-sized image the image is becoming blank(0bytes).. Problem is occurring after the imagecopyresampled function is called.. please help what is ther error with the above code///

    Hi vattanthoma,

    This is what PHP Manual has to say about your error,

    bool imagepng ( resource $image [, string $filename [, int $quality [, int $filters ]]] )

    quality : Compression level: from 0 (no compression) to 9.

    😃

      More specifically this line:

      imagepng($newImage,$image,90);

      shows the Quality (aka compression level) argument as 90 (which as you may have noticed is not between 0 and 9)

        Write a Reply...