64997

How can I save TKinter PhotoImage to .GIF?

Can I save a tkinter PhotoImage as .gif (or any other image extension) using only Python and tkinter?

Answer1:

Assuming photo is the variable holding your image, you should be able to just say:

photo.write('some_name.gif', format='gif')

I couldn't find a list of what formats are supported, but I think the list is really limited (I can confirm that gif worked for me though).

Answer2:

Looks like the method write can be used to save a PhotoImage to a file.

>>> help(Tkinter.PhotoImage.write) Help on method write in module Tkinter: write(self, filename, format=None, from_coords=None) unbound Tkinter.PhotoImage method Write image to file FILENAME in FORMAT starting from position FROM_COORDS.

Sample usage would be something like:

my_photo_image.write("output.gif")

Recommend

  • C++ equivalent of python: tf.Graph.get_tensor_by_name() in Tensorflow?
  • How to accept hash parameters in routes
  • stop image from moving when reaching the border of a container
  • How to save a large fractal image with the least possible memory footprint?
  • Embed multiple jpeg images into EXCEL programmatically?
  • How to use java.time.LocalDate on a Play Framework JSON Rest?
  • AWS S3 implementation for serving private files
  • How to restrict number of concurrent processes?
  • iOS Date formatting
  • Return null in boolean to checkbox state converter in XAML
  • segue from landscape only to portrait only
  • Azure table query partial partitionkey guid match
  • Telegram bot API - Inline bot getting Error 400 while trying to answer inline query
  • SIP API media codecs
  • Does Apportable support to build library binary (.a/.so)?
  • Thread safety of a fluent like class using clone() and non final fields
  • Email format validation in mvc3 view
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • What is Eclipse's Declaration View used for?
  • How to add date and time under each post in guestbook in google app engine
  • Updating server-side rendering client-side
  • htaccess rewriting URLs with multiple forward slashes
  • Weird JavaScript statement, what does it mean?
  • Font Awesome Showing Box instead of Icons
  • How do you troubleshoot character encoding problems?
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • WOWZA + RTMP + HTML5 Playback?
  • How to format a variable of double type
  • coudnt use logback because of log4j
  • Turn off referential integrity in Derby? is it possible?
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Add sale price programmatically to product variations
  • Is it possible to post an object from jquery to bottle.py?
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • How to Embed XSL into XML
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases
  • How do I use LINQ to get all the Items that have a particular SubItem?