How to break gif format and create small png format using python?
![qa-featured](https://www.techyv.com/sites/default/users/superadmin/qa-featured-300x270.png)
Hi,
I need your help. I have some gif pictures. I need to break its format and create small png format pictures using python. How can I do it? Please, tell me in details.
Thanks
![](https://techyv.com/sites/default/2016/10/techpedia_logo.png)
Hi,
I need your help. I have some gif pictures. I need to break its format and create small png format pictures using python. How can I do it? Please, tell me in details.
Thanks
Hello Trojan Helan, I order to create png format pictures from gif using python, you would normally use Python Image Library (PIL). Here is its link: http://www.pythonware.com/library/pil/handbook/index.htm You will find in detail help at this website, I suggest you take a look at The Imagedraw Module in Part Two and PNG file format in the appendix.
Â
Hey Trojan,
Use the following code to be able to convert gif format to png using Python. There are many open source projects online that offer this method.
Â
importImage,glob,os
files = glob.glob("small/*.gif")
forimageFile infiles:
   filepath,filename = os.path.split(imageFile)
   filterame,exts = os.path.splitext(filename)
   print"Processing: "+ imageFile,filterame
   im = Image.open(imageFile)
   im.save( 'small_/'+filterame+'.png','PNG')