Jump to content

Imagecopyresampled Pixelation


x1nick

Recommended Posts

I am having trouble resizing images in php.

 

$new_image = imagecreatetruecolor($width, $height);
 #  imageantialias($new_image,true);
   imagecopyresampled($new_image,$this->image,0,0,$x,$y,$width,$height,$new_width,$new_height);

 

It works, just the end image is pixelated, tried with imageantialias and without. Still no joy.

Its mainly pixelation around things, eg person on white background. The white would be pixelated.

 

Some server info

GD Version bundled (2.0.34 compatible)

PHP Version 5.2.9

 

Any suggestions would be appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/173339-imagecopyresampled-pixelation/
Share on other sites

You shouldn't be using JPEG format images if you don't want that to occur. This isn't a code issue. Idealy you should be using PNG or another lossless image format. JPEG isn't lossless so every time it's processed it tends to get messed up.

Try setting quality=100 when calling imagejpeg.

 

By the way, it's called JPEG artifacts, not pixelation. That's something different. Pixelation is when the individual pixels in a picture is visible to the human eye. That's not the case here. JPEG artifacts occur because JPEG is using lossy compression, like AlexWD said.

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.