isaacgerg / images2gif Goto Github PK
View Code? Open in Web Editor NEWimages2gif.py for Python 3
images2gif.py for Python 3
from images2gif import readGif as readGif
from images2gif import writeGif as writeGif
import os
import os.path
from PIL import Image
root = input('select folder')
giflist = []
for parent,dirnames,filenames in os.walk(root):
for filename in filenames:
# print("filename is:" + filename)
# print("the full name of the file is:" + os.path.join(parent,filename))
img = Image.open(os.path.join(parent,filename))
giflist.append(img)
writeGif('111.gif',giflist)
I am using the 1.0.1 version with python 2 in ubuntu 18.04 and I get this error when executing writeGif:
TypeError Traceback (most recent call last)
<ipython-input-26-613e7b96e6d8> in <module>()
22 images = [Image.fromarray(arr) for arr in images]
23 local_gif = os.path.join(dest_dir, ff)
---> 24 writeGif(local_gif, images, duration=2)
25 break
/usr/local/lib/python2.7/dist-packages/images2gif/images2gif.pyc in writeGif(filename, images, duration, repeat, dither, nq, subRectangles, dispose)
569 # Check subrectangles
570 if subRectangles:
--> 571 images, xy, images_info = gifWriter.handleSubRectangles(images, subRectangles)
572 defaultDispose = 1 # Leave image in place
573 else:
/usr/local/lib/python2.7/dist-packages/images2gif/images2gif.pyc in handleSubRectangles(self, images, subRectangles)
293
294 # Determine the sub rectangles
--> 295 images, xy = self.getSubRectangles(images)
296
297 # Done
/usr/local/lib/python2.7/dist-packages/images2gif/images2gif.pyc in getSubRectangles(self, ims)
345
346 # Cut out and store
--> 347 im2 = im[y0:y1,x0:x1]
348 prev = im
349 ims2.append(im2)
TypeError: only integer scalar arrays can be converted to a scalar index
Can somebody provide an answer or fix it? I am loading the PIL Images using numpy arrays, I have also tryed loading png directly but i got the same error.
Many thanks!
Hi,
Thank you very much for your work.
I tried your code and I just want to tell you about a problem I noticed with PIL images.
On line 260 you have: image_info = [im.flags for im in images ] but PIL images do not have the flag
attribute.
In order to run the code I have simply removed all the image_info and images_info variables as I saw they are never used.
Hope I told you something useful
Best regards,
Luca
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.