Python Forum
Want to take a Screenshot from a File in Linux
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Want to take a Screenshot from a File in Linux
#1
We are currently working manually to get a screen shot by opening every text files(screencapture from position A to position B) and save in png/jpeg format.

Is there any way to automate this in Python?

will pyscreenshot or PIL work in this case?
Just installed these LIBs.
Reply
#2
Never used pyscreenshot, but it looks it could do the job.
You can also check PyAutoGUI
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
I have got pyscreenshot (+ gtkpixbuf ) to do this activiy.

Code in gtkpixbuf.py as follows:
# http://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-linux


from PIL import Image
import tempfile

# based on:

class GtkPixbufWrapper(object):
    name = 'pygtk'
    childprocess = False

    def __init__(self):
        import gtk
        self.gtk = gtk
        try:
            gtk.gdk.Pixbuf
            gtk.gdk.COLORSPACE_RGB
        except AttributeError:
            raise ImportError(
                'Incompatible with Python3 / GDK3. Use gdk3pixbuf.')

    def grab(self, bbox=None):
        f = tempfile.NamedTemporaryFile(
            suffix='.png', prefix='pyscreenshot_gtkpixbuf_')
        filename = f.name
        self.grab_to_file(filename, bbox)
        im = Image.open(filename)
        return im

    def grab_to_file(self, filename, bbox=None):
        """http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html.

        only "jpeg" or "png"
        """


  
can anyone help how to invoke pyscreenshot and gtkpixbuf to get the screenshot of a given unix file
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  create exe file for linux? korenron 2 962 Mar-22-2023, 01:42 PM
Last Post: korenron
  IEDriverServer screenshot ABVSVL 0 1,722 Jul-12-2020, 09:31 AM
Last Post: ABVSVL
  pyautogui.screenshot region is not working alexlu 6 6,476 Jun-04-2020, 10:46 AM
Last Post: alexlu
  What is the best way to search for a pixel in a screenshot? TheZadok42 1 2,586 May-15-2020, 12:37 PM
Last Post: scidam
  Run .py file in Kali Linux Terminal grayarea3 4 28,544 Feb-27-2019, 06:51 PM
Last Post: buran
  Screenshot of specific window kainev 10 19,295 Nov-30-2018, 03:07 PM
Last Post: kainev
  datetime with every screenshot name evilcode1 7 5,492 Aug-27-2018, 06:01 PM
Last Post: buran
Question [Help] Convert integer to Roman numerals? {Screenshot attached} vanicci 10 9,130 Aug-06-2018, 05:19 PM
Last Post: vanicci
  [Help] sorted() in while loop with user's input() {Screenshot attached} vanicci 5 4,003 Aug-04-2018, 08:59 PM
Last Post: vanicci
Question [Help] How to end While Loop using counter? {Screenshot attached} vanicci 2 3,079 Aug-02-2018, 10:09 PM
Last Post: vanicci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020