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 8436063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:05:16+00:00 2026-06-10T07:05:16+00:00

I’d like to access the graphics in the linux clipboard, to save it as

  • 0

I’d like to access the graphics in the linux clipboard, to save it as a file.
I’m doing this in a Python/Tkinter program, so I asked about it (http://stackoverflow.com/questions/6817600/save-the-image-in-the-clipboatd-in-python-tkinter) but internally (in python) there’s no hope.

Instead, I can accept to use an external utility to do it – yet I cannot find one.

Do you know of any terminal-based utility able to take the clipboard content and save it as an image file?

  • 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-06-10T07:05:18+00:00Added an answer on June 10, 2026 at 7:05 am

    I couldn’t find any tool to do it, so I wrote this small Python script. It requires pygtk.

    #!/usr/bin/python
    """
    Save image from clipboard to file
    """
    
    import sys
    import glob
    from optparse import OptionParser
    
    def def_file():
        """
        Return default file name
        """
        files = glob.glob("img???.png")
        if len(files) < 1:
            return 'img001.png'
        maxf = 0
        for f in files:
            try:
                n = int(f[3:6])
                maxf = max(n, maxf)
            except ValueError:
                pass
        return 'img{:03d}.png'.format(maxf+1)
    
    
    usage = """%prog [option] [filename]
    Save image from clipboard to file in PNG format."""
    
    op = OptionParser(usage=usage)
    op.add_option("-o", "--open", action="store_true", dest="open", default=False, 
            help="Open saved file with default program (using xdg-open)")
    (options, args) = op.parse_args()
    
    if len(args) > 1:
        parser.error("Only one argument expected")
        sys.exit(1)
    elif len(args) == 1:
        fname = args[0]
    else:
        fname = def_file()
    
    import gtk
    clipboard = gtk.clipboard_get()
    image = clipboard.wait_for_image()
    if image is not None:
        image.save(fname, "png")
        print "PNG image saved to file", fname
        if options.open:
            import subprocess
            subprocess.call(["xdg-open", fname])
    else:
        print "No image in clipboard found"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,

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.