PHP: imagepng() creates broken image -
i have problem creating thumnail of png image.
this works:
$src = imagecreatefromjpeg("http://www.gaze.se/".$folder.$filename); $rootfolder = $_server['document_root'] ; $tmp = imagecreatetruecolor($targ_w, $targ_h); imagecopyresampled($tmp, $src, 0,0,$_post['x'],$_post['y'],$targ_w,$targ_h,$_post['w'],$_post['h']); imagejpeg($tmp, $rootfolder.$folder.'thumb_'.$filename,100); imagedestroy($tmp); imagedestroy($src);
then change 2 jpeg functions png, this:
$src = imagecreatefrompng("http://www.gaze.se/".$folder.$filename); $rootfolder = $_server['document_root'] ; $tmp = imagecreatetruecolor($targ_w, $targ_h); imagecopyresampled($tmp, $src, 0,0,$_post['x'],$_post['y'],$targ_w,$targ_h,$_post['w'],$_post['h']); imagepng($tmp, $rootfolder.$folder.'thumb_'.$filename,100); imagedestroy($tmp); imagedestroy($src);
but image broken, message shows when try open it:
any ideas of how solve this?
check out http://php.net/manual/en/function.imagepng.php. $quality parameter should 0 9 png files. , @jeroen said, should check return values.
Comments
Post a Comment