I have the following issue: I extract the different frames of a gif in several PNG files with:
def extractFrames(inGif, outFolder):
frame = Image.open(inGif)
nframes = 0
while frame:
frame.save( '%s/%s-%s.png' % (outFolder, os.path.basename(inGif), nframes ) , 'PNG')
nframes += 1
try:
frame.seek( nframes )
except EOFError:
break;
return True
That works as intended. However if I run the following piece of code:
im = Image.open(item) #item is one of the earlier created PNGs
pix = im.load()
for x in range(0,im.size[0]):
for y in range(0,im.size[1]):
print pix[x,y]
The output will be something like 13
or 3
instead of the intended (255, 255, 255, 255)
.
Once I open the files in Paint and save them without modifying anything, the script runs just fine and outputs a tuple with (R, G, B, A)
.
So my question is: Why is that and how can I modify the code that I don't have to open all images manually before running the second part of the code?
Edit: I tried the whole thing initially with extracting the framess into GIFs instead of PNGs, with the same result.