PIL JPEG pixel problem

Kevin@Cazabon.com kevin at cazabon.com
Tue Jan 7 18:47:36 EST 2003


As the others have said, JPEG is lossy.

You'll get closer to the original result by specifying "quality=100" in the
save method, but the only way to get EXACTLY what you want is to use a
non-lossy format.

(i.e. x.save("c:\asdf.jpg", quality=100)  )

Kevin.


"Mark" <itcram at yahoo.com> wrote in message
news:df392399.0301070946.5455fd55 at posting.google.com...
> I'm having problems changing the pixels in a .jpg file.
>
> >>>import Image
> >>> x = Image.open('te.jpg')
> >>> x.getpixel((0,0))
> (255, 255, 255)
> >>> x.putpixel((0,0),(100,150,165))
> >>> x.save('asdf.jpg')
> >>>
> >>> x = Image.open('asdf.jpg')
> >>> x.getpixel((0,0))
> (146, 146, 146)
>
> When I open it up after changing the pixels they are I get totally
> different pixels from (100,150,165) to (146,146,146).  I've tried
> using the different options in the save() method(not all possible
> combonations), but they always are different.  Does anyone know how I
> can fix this?
>
> Thanks!






More information about the Python-list mailing list