Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:40:34+00:00 2026-05-28T17:40:34+00:00

I want to open a GIF image from the python console in Linux. Normally

  • 0

I want to open a GIF image from the python console in Linux. Normally when opening a .png or .jpg, I would do the following:

>>> from PIL import Image                                                                                
>>> img = Image.open('test.png')
>>> img.show()

But if I do this:

>>> from PIL import Image                                                                                
>>> img = Image.open('animation.gif')
>>> img.show()

Imagemagick will open but only show the first frame of the gif, not the animation.

Is there a way to show the animation of the GIF in a viewer in Linux?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:40:35+00:00Added an answer on May 28, 2026 at 5:40 pm

    Image.show dumps the image to a temporary file and then tries to display the file. It calls ImageShow.Viewer.show_image (see /usr/lib/python2.7/dist-packages/PIL/ImageShow.py):

    class Viewer:
        def save_image(self, image):
            # save to temporary file, and return filename
            return image._dump(format=self.get_format(image))
        def show_image(self, image, **options):
            # display given image
            return self.show_file(self.save_image(image), **options)
        def show_file(self, file, **options):
            # display given file
            os.system(self.get_command(file, **options))
            return 1
    

    AFAIK, the standard PIL can not save animated GIfs1.

    The image._dump call in Viewer.save_image only saves the first frame. So no matter what viewer is subsequently called, you only see a static image.

    If you have Imagemagick’s display program, then you should also have its animate program. So if you have the GIF as a file already, then you could use

    animate /path/to/animated.gif
    

    To do so from within Python, you could use the subprocess module (instead of img.show):

    import subprocess
    
    proc = subprocess.Popen(['animate', '/path/to/animated.gif'])
    proc.communicate()
    

    1 According to kostmo, there is a script to save animated GIFS with PIL.


    To show the animation without blocking the main process, use a separate thread to spawn the animate command:

    import subprocess
    import threading
    
    def worker():
        proc = subprocess.Popen(['animate', '/path/to/animated.gif'])
        proc.communicate()
    
    t = threading.Thread(target = worker)
    t.daemon = True
    t.start()
    # do other stuff in main process
    t.join()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to open some relative big files (jpg, gif, bmp) using as little
I want to be able to open either a .jpg, .gif or .bmp into
Hay, I want to use PHP's GD library to open a GIF image and
I want open a path to vim from Screen's copy-mode by Ctrl-A f similarly
I want to open a folder window, in the appropriate file manager, from within
I want to open a TCP client socket in Python. Do I have to
I want to open a file from a Class in C# using a Process,
I want to open Multiple Instance of a single from , and running simultaneously
i want to crop a photo retrieved from database, i have done the following
I want a loading gif image to appear while processing a servlet. What I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.