

{"id":107986,"date":"2022-03-02T09:00:28","date_gmt":"2022-03-02T03:30:28","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=107986"},"modified":"2026-06-01T12:53:40","modified_gmt":"2026-06-01T07:23:40","slug":"python-gif-generator-project","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/","title":{"rendered":"Create Animated GIF using Python"},"content":{"rendered":"<p>We all use GIFs almost every day as a form of communication. These visual messages are attracting users of all ages. Have you ever wanted to create your own? Yes!! We are here with a project for GIF Generator using Python. Let\u2019s not wait and start with the introduction.<\/p>\n<h3>What is a GIF?<\/h3>\n<p>Graphics Interchange Formats, GIFs, are a series of animated images that give a sense of motion. These are being used by most people to communicate with others on social media platforms like WhatsApp, Instagram, etc. Here we will be building a GIF Creator that creates a GIF from the images.<\/p>\n<h3>GIF Creator using Python<\/h3>\n<p>In this project, we will be using the Tkinter, glob, and imageio modules for development purposes. We use the Tkinter module to build a GUI to take the inputs of users about the path of images to be converted to GIF and their extension. And the glob is used to extract the files from the device. At last, we use the imageio to read the images and convert them to a GIF.<\/p>\n<h3>Download the GIF Creator Project<\/h3>\n<p>Please download the source code for the GIF Creator project using the link: <a href=\"https:\/\/drive.google.com\/file\/d\/1Hryibh5KXNCw5KTfJNook4enLDvkvJeX\/view?usp=drive_link\"><strong>GIF Creator using Python<\/strong><\/a><\/p>\n<h3>Project Prerequisites<\/h3>\n<p>Prior knowledge of Python, Tkinter, and glob is useful. And the following commands can be used to install the modules discussed above.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install tkinter\r\npip install glob2\r\npip install imageio\r\n\r\n<\/pre>\n<h3>Steps to build the Python GIF Creator<\/h3>\n<p>Now it&#8217;s time to build the project. Let\u2019s first discuss the steps to build the project.<\/p>\n<ol>\n<li>The first step is to import the required modules.<\/li>\n<li>Then we create the GUI and add the required widgets.<\/li>\n<li>Finally, we write the function to convert the images and run the code.<\/li>\n<\/ol>\n<h4>1. Importing the Modules<\/h4>\n<p>We import all the modules glob, tkinter, and imageio whose use we have just discussed above. We use the messagebox to show the pop up message once the GIF is saved.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Importing modules\r\nimport glob\r\nfrom tkinter import *\r\nfrom tkinter import messagebox\r\nimport imageio<\/pre>\n<h4>2. Creating the GUI<\/h4>\n<p>The next step is to create a GUI for taking the input from the user.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Creating the window\r\nwn = Tk()\r\nwn.title(\"DataFlair GIF Creator\")\r\nwn.geometry('500x300')\r\nwn.config(bg='azure')<\/pre>\n<h4>3. Adding the Widgets<\/h4>\n<p>Now we add the widgets to the GUI created. The first widget is a pair of radio buttons to select the extension of the images as either .png or .jpeg. The variable \u2018extension\u2019 will hold the value based on the selection of the radio buttons.<\/p>\n<p>Then we take the input of the path of the folder with the images. After this, on pressing the button the GIF gets created.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Creating the variables to get the path of folder and the extension of images\r\nextension = StringVar(wn)\r\ndirec=StringVar(wn)\r\n\r\n#The main label\r\nLabel(wn, text='DataFlair GIF Creator',bg='azure',\r\nfg='black', font=('Times', 20,'bold')).place(x=60, y=10)\r\n\r\n#Getting the extension of the image as either png or jpeg\r\nLabel(wn, text='Please select the extension of the images',bg='azure2', anchor=\"e\", justify=LEFT).place(x=20, y=70)\r\n\r\nRadiobutton(wn, text='png',bg='azure2', variable=extension, value='png').place(x=50,y=100)\r\nRadiobutton(wn, text='jpeg',bg='azure2',variable=extension, value='jpeg').place(x=150,y=100)\r\n\r\n#Getting the path of the folder with the images\r\nLabel(wn, text='Please enter the folder location where images exist',bg='azure2', anchor=\"e\", justify=LEFT).place(x=20, y=130)\r\n\r\nEntry(wn,textvariable=direc, width=35, font=('calibre',10,'normal')).place(x=200,y=160)\r\n\r\n#Button to convert the images into GIF and save the GIF\r\nLabel(wn, text='Please click the button to get the GIF', bg='azure2',anchor=\"e\", justify=LEFT).place(x=20, y=190)\r\n\r\nButton(wn, text=\"Click Me\", bg='ivory3',font=('calibre', 13),\r\ncommand=convertToGIF).place(x=230, y=220)\r\n\r\n#Runs the window till it is closed by the user\r\nwn.mainloop()<\/pre>\n<h4>4. Function to Get the Images and convert to GIF<\/h4>\n<p>This function executes when the user presses the button. In this function, we get the path of the folder and extension<br \/>\nThen we get the directories of all the images in the folder using glob. Then we read these images and store in imgs list<\/p>\n<p>Finally, we create the gif from the images in the imgs list and save it<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Function to convert Images to GIF\r\ndef convertToGIF():\r\npath = direc.get() #Get the path of the folder entered by the user\r\next=extension.get() #Get the extension png or jpeg\r\npath_in =path+'\/*.'+ext #Creating the final path of the images\r\npath_out = path+\"\/MyGif.gif\" #Creating the path for GIF in the same folder as the images\r\n\r\nimgs=[] #list to store all the images\r\ntry:\r\nfile = glob.glob(path_in, recursive = True) #Recursively getting the paths of all the images in the folder\r\nfor im in file:\r\nimgs.append(imageio.imread(im)) #Reading all the images\r\n\r\nimageio.mimsave(path_out, imgs) #Converting the images to GIF and saving it\r\n#Showing the message box on saving the gif\r\nmessagebox.showinfo(\"DataFlair GIF Generator\",\"GIF is saved successfully in the folder with Images!\")\r\nexcept:\r\n#Showing a message if not able to collect the images or convert them to gif\r\nmessagebox.showinfo(\"Error occurred!\",\"Please check the path of the folder or the extension of images.\")<\/pre>\n<h3>Python GIF Creator Output<\/h3>\n<p>Image of pop up message on saving the GIF<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-gif-creator-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108029\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-gif-creator-output.webp\" alt=\"python gif creator output\" width=\"624\" height=\"413\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Summary<\/h3>\n<p>Congratulations! You have successfully learned to create a GIF from the images using Python GIF Generator Project. Hope you liked this project. Enjoy building your own gifs and sharing them with your friends!<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2563,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1Hryibh5KXNCw5KTfJNook4enLDvkvJeX\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601072406\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1Hryibh5KXNCw5KTfJNook4enLDvkvJeX\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-01 11:58:28&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-07 00:20:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-16 03:46:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-19 08:54:12&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-19 08:54:12&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We all use GIFs almost every day as a form of communication. These visual messages are attracting users of all ages. Have you ever wanted to create your own? Yes!! We are here with&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":108027,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[26644,26645,26639,21082,22734,26640],"class_list":["post-107986","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python-gif","tag-python-gif-creator","tag-python-gif-generator-project","tag-python-project","tag-python-project-for-beginners","tag-python-project-to-create-gif"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create Animated GIF using Python - DataFlair<\/title>\n<meta name=\"description\" content=\"Create a project in Python for GIF generator using Tkinter, glob, and imageio modules for development purposes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Animated GIF using Python - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Create a project in Python for GIF generator using Tkinter, glob, and imageio modules for development purposes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-02T03:30:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T07:23:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-project-create-animated-gif.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Animated GIF using Python - DataFlair","description":"Create a project in Python for GIF generator using Tkinter, glob, and imageio modules for development purposes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/","og_locale":"en_US","og_type":"article","og_title":"Create Animated GIF using Python - DataFlair","og_description":"Create a project in Python for GIF generator using Tkinter, glob, and imageio modules for development purposes.","og_url":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2022-03-02T03:30:28+00:00","article_modified_time":"2026-06-01T07:23:40+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-project-create-animated-gif.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"Create Animated GIF using Python","datePublished":"2022-03-02T03:30:28+00:00","dateModified":"2026-06-01T07:23:40+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/"},"wordCount":529,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-project-create-animated-gif.webp","keywords":["python gif","python gif creator","Python GIF Generator Project","Python project","python project for beginners","Python project to create GIF"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/","url":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/","name":"Create Animated GIF using Python - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-project-create-animated-gif.webp","datePublished":"2022-03-02T03:30:28+00:00","dateModified":"2026-06-01T07:23:40+00:00","description":"Create a project in Python for GIF generator using Tkinter, glob, and imageio modules for development purposes.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-project-create-animated-gif.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-project-create-animated-gif.webp","width":1200,"height":628,"caption":"python project create animated gif"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-gif-generator-project\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Create Animated GIF using Python"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/107986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=107986"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/107986\/revisions"}],"predecessor-version":[{"id":148642,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/107986\/revisions\/148642"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/108027"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=107986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=107986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=107986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}