I cropped an image using PHP GD imagecopyresampled()
function.
I used the function in the past, but now it seems that somehow, for browsers like Firefox & Chrome (latest versions of both) the image is not really cropped, but somehow transparent in the part that should be removed.
The OSX finder and Photoshop shows correct image sizes and no transparency...
What could be wrong?
This is the code for jpg images...
if(!($sourceImage = @imagecreatefromjpeg($source)))
{
$image = imagecreate($width, $height);
$colorWhite = imagecolorallocate($image, 255, 255, 255);
$colorBlack = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $colorWhite);
imagestring($image, 1, 1, 10, "Immagine non disponibile", $colorBlack);
imagejpeg($image, $destination);
return(FALSE);
}
$destinationImage = imagecreatetruecolor($width, $height);
imagecopyresampled($destinationImage, $sourceImage,0,0,$x,$y,$width,$height,$width,$height);
imagejpeg($destinationImage, $destination);