save - Python PIL library - Saving an image from a RGBA array -
I am currently using the PIL library to manipulate pixel colors in an image.
My problem is I do not know how to save a RGB array in a png file.
image = Image.open (filepath) pixels = image.load ()
... after changing RGB values in pixels eg
pixels [2,10] = 30, 40, 50, 60
Then if I try to save the pixels like this:
pixel. Save (path)
I get an error
attributeError: 'PixelAccess' has no attribute in object' Save '
How do I save the pixels in a PNG file?
(sorry in advance if this is a stupid question)
Thank you! Andrew
This is an image object that contains the save
method, not the pixel access Object.
Modifying the pixel access object can also modify the image. Therefore saving the image is very similar to saving the pixel access object.
Comments
Post a Comment