Saving Image with PIL
As I hate to see questions without a complete answer:
from PIL import Image
newImg1 = Image.new('RGB', (512,512))
for i in range (0,511):
for j in range (0,511):
newImg1.putpixel((i,j),(i+j%256,i,j))
newImg1.save("img1.png")
which yields a test pattern.
To use array style addressing on the image instead of putpixel, convert to a numpy array:
import numpy as np
pixels = np.asarray(newImg1)
pixels.shape, pixels.dtype
-> (512, 512, 3), dtype('uint8')
PIL isn't an attribute of newImg1 but newImg1 is an instance of PIL.Image so it has a save method, thus the following should work.
newImg1.save("img1.png","PNG")
Note that just calling a file .png doesn't make it one so you need to specify the file format as a second parameter.
try:
type(newImg1)
dir(newImg1)
and
help(newImg1.save)