{"id":87489,"date":"2023-05-08T10:34:55","date_gmt":"2023-05-08T05:04:55","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=87489"},"modified":"2026-06-03T15:40:10","modified_gmt":"2026-06-03T10:10:10","slug":"python-image-format-converter","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/","title":{"rendered":"Python Image Format Converter &#8211; Say Goodbye to Format Woes"},"content":{"rendered":"<p>Many times we need different formats of image as their size differs. Image format converters convert one form of image to another by changing their extensions, like.jpg to.png or.png to.jpg, etc. So we&#8217;ll make a graphical user interface for it, covering a few extensions like .jpg ,.png, and .web.<\/p>\n<h3>What is Tkinter?<\/h3>\n<p>Python offers various utilities to design the GUI wiz Graphical User Interface, and one such utility is Tkinter which is most commonly used. It is one of the fastest and easiest ways to build GUI applications. Moreover, Tkinter is cross-platform. As a result, the same code works on macOS, Windows, and Linux.<\/p>\n<h3>Prerequisites for Image Format Converter using Python<\/h3>\n<ul>\n<li>Basic knowledge of the Python programming language, how functions are defined,<\/li>\n<li>How the window is created in Tkinter GUI, as well as the frame.<\/li>\n<li>Understand the Pillow library for editing, creating, and saving images.<\/li>\n<\/ul>\n<h3>Download Python Image Format Converter Project<\/h3>\n<p>Please download the source code of Python Image Format Converter Project from the following link: <a href=\"https:\/\/drive.google.com\/file\/d\/1NplNc5eGAQQVQT7uW4pZ-Ab64EF03qaH\/view?usp=drive_link\"><strong>Python Image Format Converter Project Code<\/strong><\/a><\/p>\n<h3>Steps to Create Image Format Converter Project using Python<\/h3>\n<p>Following are the steps for developing the Python Image Format Converter Project:<\/p>\n<p><strong>Step 1:<\/strong> Importing the necessary modules<br \/>\n<strong>Step 2:<\/strong> Making a window for our project<br \/>\n<strong>Step 3:<\/strong> Functions<br \/>\n<strong>Step 4:<\/strong> Making Frames and Mapping the Buttons to Their Functionalities<\/p>\n<h4>Step 1: Importing the necessary modules<\/h4>\n<p>To use Tkinter, we need to import the Tkinter module. We are also going to import the Image, messagebox and filedialog module<\/p>\n<p><strong>Code<br \/>\n<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#import packages\r\nfrom PIL import Image\r\nimport tkinter as tk\r\nfrom tkinter import filedialog\r\nfrom tkinter import messagebox<\/pre>\n<h4>Step 2: Making a window for our project<\/h4>\n<p>This code sets the title of the window as \u2018TechVidvan Image Format Converter\u2019, and sets the dimensions \u2018width x length\u2019.<\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">root = tk.Tk()\r\nroot.geometry(\"300x300\")\r\nroot.title(\"TechVidvan Image Format Converter\")\r\n<\/pre>\n<h4>Step 3: Functions<\/h4>\n<p>These functions convert an input image to the required format and save it at the location where the user wants to store it.<\/p>\n<p><strong> Step 3.1: select():<\/strong><\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def select():\r\n   global img_1\r\n   img = filedialog.askopenfilename(title=\"Select a Image\")\r\n   entry1.delete(0, tk.END)\r\n   entry1.insert(0, img)\r\n   img_1 = Image.open(img)\r\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<p><strong>Image.open<\/strong> is used to open an image, and<strong> filedialog.askopenfilename<\/strong> is used to select an image from the device.<\/p>\n<p><strong>Step 3.2: jpg(), png(), webp():<\/strong><\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def jpg():\r\n   global img_1\r\n   img_2 = filedialog.asksaveasfilename(\r\n       defaultextension='.jpg')\r\n   img_1 = img_1.convert('RGB')\r\n   img_1.save(img_2)\r\n   messagebox.showinfo(\"TechVidvan(Congrats)\", \"Converted to JPG\")\r\n\r\n\r\n\r\n\r\ndef png():\r\n   global img_1\r\n   img_2 = filedialog.asksaveasfilename(\r\n       defaultextension='.png')\r\n   img_1.save(img_2)\r\n   messagebox.showinfo(\"TechVidvan(Congrats)\", \"Converted to PNG\")\r\n\r\n\r\n\r\n\r\ndef webp():\r\n   global img_1\r\n   img_2 = filedialog.asksaveasfilename(\r\n       defaultextension='.webp')\r\n   img_1.save(img_2)\r\n   messagebox.showinfo(\"TechVidvan(Congrats)\", \"Converted to Webp\")\r\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<p><strong>Filedialog.asksaveasfilename<\/strong> is used to create a new file of the required format, and in each function, we mention the default extension in which we want to convert the image, and <strong>img_1.save<\/strong> is used to save the converted image.<\/p>\n<h4>Step 4: Making Frames and Mapping the Buttons to Their Functionalities<\/h4>\n<p>We make four frames, and in each frame we give button modules; in frame 1, we get input from the user, i.e., the input image; and in the remaining frames, we give options of different formats from which the user can select whichever output image format they want.<\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#make four frames and button function for each frame\r\nframe1 = tk.Frame(root)\r\nframe1.pack(pady=20)\r\n\r\n\r\n\r\n\r\nl1 = tk.Label(frame1, text=\"Select:\")\r\nl1.pack(side=\"left\", padx=10)\r\nbutton1 = tk.Button(frame1, text=\"Upload Image\", width=20, command=select)\r\nbutton1.pack(padx=10)\r\nentry1 = tk.Entry(frame1, width=30)\r\nentry1.pack(side=\"left\",pady=10)\r\n\r\n\r\nframe2 = tk.Frame(root)\r\nframe2.pack(pady=20)\r\n\r\n\r\nbutton2 = tk.Button(frame2, text=\"To JPG\", width=20, command=jpg)\r\nbutton2.pack(padx=10)\r\n\r\n\r\nframe3 = tk.Frame(root)\r\nframe3.pack(pady=20)\r\n\r\n\r\nbutton3 = tk.Button(frame3, text=\"To PNG\", width=20, command=png)\r\nbutton3.pack(padx=10)\r\n\r\n\r\nframe4 = tk.Frame(root)\r\nframe4.pack(pady=20)\r\n\r\n\r\nbutton4 = tk.Button(frame4, text=\"To Webp\", width=20, command=webp)\r\nbutton4.pack(padx=10)\r\n\r\n\r\nroot.mainloop()\r\n<\/pre>\n<p><strong>Full Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from PIL import Image\r\nimport tkinter as tk\r\nfrom tkinter import filedialog\r\nfrom tkinter import messagebox\r\n\r\n\r\nroot = tk.Tk()\r\nroot.geometry(\"300x300\")\r\nroot.title(\"TechVidvan Image Format Converter\")\r\n\r\n\r\nglobal img_1\r\n\r\n\r\n\r\n\r\ndef select():\r\n   global img_1\r\n   img = filedialog.askopenfilename(title=\"Select a Image\")\r\n   entry1.delete(0, tk.END)\r\n   entry1.insert(0, img)\r\n   img_1 = Image.open(img)\r\n\r\n\r\n\r\n\r\ndef jpg():\r\n   global img_1\r\n   img_2 = filedialog.asksaveasfilename(\r\n       defaultextension='.jpg')\r\n   img_1 = img_1.convert('RGB')\r\n   img_1.save(img_2)\r\n   messagebox.showinfo(\"TechVidvan(Congrats)\", \"Converted to JPG\")\r\n\r\n\r\n\r\n\r\ndef png():\r\n   global img_1\r\n   img_2 = filedialog.asksaveasfilename(\r\n       defaultextension='.png')\r\n   img_1.save(img_2)\r\n   messagebox.showinfo(\"TechVidvan(Congrats)\", \"Converted to PNG\")\r\n\r\n\r\n\r\n\r\ndef webp():\r\n   global img_1\r\n   img_2 = filedialog.asksaveasfilename(\r\n       defaultextension='.webp')\r\n   img_1.save(img_2)\r\n   messagebox.showinfo(\"TechVidvan(Congrats)\", \"Converted to Webp\")\r\n\r\n\r\n\r\n\r\nframe1 = tk.Frame(root)\r\nframe1.pack(pady=20)\r\n\r\n\r\n\r\n\r\nl1 = tk.Label(frame1, text=\"Select:\")\r\nl1.pack(side=\"left\", padx=10)\r\nbutton1 = tk.Button(frame1, text=\"Upload Image\", width=20, command=select)\r\nbutton1.pack(padx=10)\r\nentry1 = tk.Entry(frame1, width=30)\r\nentry1.pack(side=\"left\",pady=10)\r\n\r\n\r\nframe2 = tk.Frame(root)\r\nframe2.pack(pady=20)\r\n\r\n\r\nbutton2 = tk.Button(frame2, text=\"To JPG\", width=20, command=jpg)\r\nbutton2.pack(padx=10)\r\n\r\n\r\nframe3 = tk.Frame(root)\r\nframe3.pack(pady=20)\r\n\r\n\r\nbutton3 = tk.Button(frame3, text=\"To PNG\", width=20, command=png)\r\nbutton3.pack(padx=10)\r\n\r\n\r\nframe4 = tk.Frame(root)\r\nframe4.pack(pady=20)\r\n\r\n\r\nbutton4 = tk.Button(frame4, text=\"To Webp\", width=20, command=webp)\r\nbutton4.pack(padx=10)\r\n\r\n\r\nroot.mainloop()\r\n<\/pre>\n<h3>Python Image Format Converter Output<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-87721 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/04\/python-image-format-converter-output.webp\" alt=\"python image format converter output\" width=\"1918\" height=\"922\" \/><\/p>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-87722 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/04\/image-format-converter-output.webp\" alt=\"image format converter output\" width=\"1918\" height=\"792\" \/><\/h3>\n<h3>Summary<\/h3>\n<p>We can now easily convert our images into the required formats, such as jpg, png, webp, etc. by using the Python Tkinter GUI. This project provides practical exposure to various Python libraries, such as tkinter, filedialog, and Pillow to open our images and change their format.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many times we need different formats of image as their size differs. Image format converters convert one form of image to another by changing their extensions, like.jpg to.png or.png to.jpg, etc. So we&#8217;ll make&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":87719,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[4975,4976,4977,4978,1207,4968,3335],"class_list":["post-87489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-image-format-convereter-project","tag-image-format-converter","tag-python-image-format-converter","tag-python-image-format-converter-project","tag-python-project-for-practice","tag-python-project-ideas","tag-python-projects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Image Format Converter - Say Goodbye to Format Woes - TechVidvan<\/title>\n<meta name=\"description\" content=\"Our Python Image Format Converter is a powerful tool for converting image files with ease. Experience fast, efficient conversions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Image Format Converter - Say Goodbye to Format Woes - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Our Python Image Format Converter is a powerful tool for converting image files with ease. Experience fast, efficient conversions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-08T05:04:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T10:10:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/04\/python-project-image-format-converter-1.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=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan 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":"Python Image Format Converter - Say Goodbye to Format Woes - TechVidvan","description":"Our Python Image Format Converter is a powerful tool for converting image files with ease. Experience fast, efficient conversions.","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:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/","og_locale":"en_US","og_type":"article","og_title":"Python Image Format Converter - Say Goodbye to Format Woes - TechVidvan","og_description":"Our Python Image Format Converter is a powerful tool for converting image files with ease. Experience fast, efficient conversions.","og_url":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2023-05-08T05:04:55+00:00","article_modified_time":"2026-06-03T10:10:10+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/04\/python-project-image-format-converter-1.webp","type":"image\/webp"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Python Image Format Converter &#8211; Say Goodbye to Format Woes","datePublished":"2023-05-08T05:04:55+00:00","dateModified":"2026-06-03T10:10:10+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/"},"wordCount":496,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/04\/python-project-image-format-converter-1.webp","keywords":["image format convereter project","image format converter","python image format converter","python image format converter project","Python project for practice","python project ideas","Python Projects"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/","url":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/","name":"Python Image Format Converter - Say Goodbye to Format Woes - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/04\/python-project-image-format-converter-1.webp","datePublished":"2023-05-08T05:04:55+00:00","dateModified":"2026-06-03T10:10:10+00:00","description":"Our Python Image Format Converter is a powerful tool for converting image files with ease. Experience fast, efficient conversions.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/04\/python-project-image-format-converter-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/04\/python-project-image-format-converter-1.webp","width":1200,"height":628,"caption":"python project image format converter"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/python-image-format-converter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Python Image Format Converter &#8211; Say Goodbye to Format Woes"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/87489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=87489"}],"version-history":[{"count":2,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/87489\/revisions"}],"predecessor-version":[{"id":448107,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/87489\/revisions\/448107"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/87719"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=87489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=87489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=87489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}