Jump to content

Resizing PNGs


mattal999

Recommended Posts

Hi,

 

I have this script:

 

<?php

header("Content-type: image/png");

$image = imagecreate(50, 100);
$src = imagecreatefrompng("http://www.ibuziness.co.uk/modules/avatars/avatar.php?ownerid=".$_GET['ownerid']);

$background = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $background);
imagealphablending($image, false);
imagesavealpha($image, true);

imagecopyresized($image, $src, 0, 0, 0, 0, 50, 100, 150, 300);
//imagecopyresampled($image, $src, 0, 0, 0, 0, 50, 100, 150, 300);
imagepng($image);
imagedestroy($image);

?>

 

which uses this image:

 

avatar.php?ownerid=244130

 

to produce:

 

smallavatar.php?ownerid=244130

 

As you can see, the image is very pixelated. I have tried both imagecopyresampled and imagecopyresized, but they produce the same result. imagecreatetruecolor produces an even worse result than imagecreate.

 

Is there any solution?

Link to comment
https://forums.phpfreaks.com/topic/136225-resizing-pngs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.