It is as simple as it gets. Make the image RGB, one pixel large. Set the pixel value (a, b, c). Save. The problem is that the saved image has a different pixel value (a, b, c). Usually, with + -1 on one of the channels, as if it were random noise, but it was consistent. Here is the code:
from PIL import Image
newImg = Image.new('RGB', (1,1), "black")
pixels = newImg.load()
pixels[0,0] = (0,3,0)
newImg.save("point.jpg")
savedImage = Image.open("point.jpg")
pixelsSaved = savedImage.load()
print pixels[0,0]
print pixelsSaved[0,0]
The way out of this: (0, 3, 0) (1, 3, 0)
sequentially.
If I use (4, 2, 0) as the pixel to save, the output is: (4, 2, 0) (3, 2, 0)
and (0,10,0) gives: (0, 10, 0) (0, 10, 1)
eg.
Why does the value change when saved? How can I prevent this? Please, help.
Thank.