I am new to PIL and Python and I have a question related to the API.
I have an Image
img = Image.new('RGB', (1, 2))
And I have a list of tuples
x = [(255, 255, 255), (255, 255, 255)]
I do img.putdata(x)
and img.save('C:\\somename.jpeg')
Later on when I reload the Image and do
img2 = Image.open('C:\\somename.jpeg')
y = [p for p in img2.getdata()]
The data 'y' that开发者_JS百科 I actually get back is
[(255, 255, 255), (251, 251, 251)]
I am not able to understand why this is happening? Please let me know if anyone has some pointers related to this.
jpeg is a lossy compression format and doesn't guarantee pixel by pixel reproduction. Try saving the image in a lossless format.
精彩评论