Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.