PHP GD - setpixel on jpeg smeared the colors

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shlomi
Forum Newbie
Posts: 1
Joined: Thu Mar 10, 2011 1:53 am

PHP GD - setpixel on jpeg smeared the colors

Post by shlomi »

hi,

i'm using the php-gd method setpixel() to set a single pixel on loaded jpg image (loaded from existing file).
the problem is that when i'm do it it's seems like the pixel smeared around the original pixel point and this method not just set the pixels itself.
maybe this occur due to i'm use the method couple of times on the same pixel with the same color so the gd not just replace the pixel but put couple of layers on it and then the result is the smeared area.
i'm a programmer and not understand the graphics depths but it's seems weird that setpixel that should set individual pixel actually effect on more than the pixels itself.
i tried to read about it via Google but seems that most of the examples are for PNG and not dealt with JPGs

do anyone know what i'm talking about and how to solve this issue?

thanks.

Shlomi.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP GD - setpixel on jpeg smeared the colors

Post by pickle »

Are you setting the pixel, then saving it as a JPG? At lower qualities, JPG compression will blur single pixels.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply