PIL JPEG pixel problem

pythonhda pythonhda at yahoo.com.replacepythonwithlinux
Tue Jan 7 19:44:46 CET 2003


jpeg is a lossy compression algorithm, I believe. So you never get back exactly what you compress (save). Try it with png and see if you get the same results.

On 7 Jan 2003 09:46:13 -0800
itcram at yahoo.com (Mark) wrote:

> 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