1

I dunno why, but there's something weird about imagepng. Whenever i use imagepng($image_p,NULL,9); it uploads the file and displays it on the page but when i use imagepng($image_p,'upload/test.png',9); it does upload the image, but the page returns the message "The image _ cannot be displayed, because it contains errors." and the succeeding codes will not work.

Can you guys please tell me what I'm doing wrong here?

here's the more detailed code:

$im = imagecreatefrompng($filename2);
$size = getimagesize($filename2);
$w = $size[0];
$h = $size[1];
$nw = 200;
$nh = 200;
$image_p = imagecreatetruecolor($nw,$nh);
imagecopyresampled($image_p,$im,0,0,$_GET['left']*1,$_GET['top']*1,$nw,$nh,$_GET['width']*1,$_GET['height']*1);
header('Content-Type: image/png');
$fn1 = "fin_".substr(uniqid(md5(rand()), true),0,10).".".$extension;
imagepng($image_p,'upload/'.$fn1,9);
MrPowerhouse
  • 63
  • 10

1 Answers1

1

I removed header('Content-Type: image/png'); and it worked. Unbelievable.

Thank you very much Fred ii for trying to help me out. I really appreciate your time.

MrPowerhouse
  • 63
  • 10