pyscreenshot | Python screenshot library , replacement for the Pillow | Computer Vision library

 by   ponty Python Version: 3.1 License: BSD-2-Clause

kandi X-RAY | pyscreenshot Summary

kandi X-RAY | pyscreenshot Summary

pyscreenshot is a Python library typically used in Artificial Intelligence, Computer Vision applications. pyscreenshot has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can install using 'pip install pyscreenshot' or download it from GitHub, PyPI.

the pyscreenshot module is obsolete in most cases. it was created because [pil][5] imagegrab module worked on windows only, but now linux and macos are also [supported][15] by pillow. there are some features in pyscreenshot which can be useful in special cases: flexible backends, wayland support, sometimes better performance, optional subprocessing. the module can be used to copy the contents of the screen to a [pillow][6] image memory using various back-ends. replacement for the [imagegrab][15] module. for handling image memory (e.g. saving to file, converting,..) please read [pillow][6] documentation. links: * home: * pypi: goal: pyscreenshot tries to allow to take screenshots without installing 3rd party libraries. it is cross-platform. it is only a pure python wrapper, a thin layer over existing back-ends. its strategy should work on most linux distributions: a lot of back-ends are wrapped, if at least one exists
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pyscreenshot has a low active ecosystem.
              It has 462 star(s) with 90 fork(s). There are 15 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 6 open issues and 61 have been closed. On average issues are closed in 267 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of pyscreenshot is 3.1

            kandi-Quality Quality

              pyscreenshot has 0 bugs and 0 code smells.

            kandi-Security Security

              pyscreenshot has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pyscreenshot code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pyscreenshot is licensed under the BSD-2-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pyscreenshot releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              pyscreenshot saves you 826 person hours of effort in developing the same functionality from scratch.
              It has 1952 lines of code, 136 functions and 89 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pyscreenshot and discovered the below as its top functions. This is intended to give you an instant insight into pyscreenshot implemented functionality, and help decide if they suit your requirements.
            • Grab a bounding box from bbox
            • Grab an image from a given bounding box
            • Grab a PNG image
            • Grab backend
            • Print out the available versions
            • Get backend version
            • Return backend s backend version
            • Grab image
            • Helper function to read a PNG image
            • Run a command from a command line
            • Grab minion image
            • Convert bbox to miner region
            • Grab image from buffer
            • Grab the contents of the widget into the given buffer
            • Grab the image from the buffer
            • Grab data from the buffer
            • Grab image from bounding box
            • Get backend version
            • Grab the current image
            • Grab a binary image
            • Grab Screen capture
            • Grab the image
            • Show backends
            • Grab an image
            • Remove all files in a directory
            Get all kandi verified functions for this library.

            pyscreenshot Key Features

            No Key Features are available at this moment for pyscreenshot.

            pyscreenshot Examples and Code Snippets

            No Code Snippets are available at this moment for pyscreenshot.

            Community Discussions

            QUESTION

            AttributeError: shape | When using skimage resize with pyscreenshot.grab() as input?
            Asked 2022-Feb-07 at 09:25

            I'm attempting to resize an image captured using pyscreenshot.grab() to 28x28 pixels

            ...

            ANSWER

            Answered 2022-Feb-07 at 09:25

            Converting userImage to a numpy array before passing to the scikit-image function does the trick.

            Source https://stackoverflow.com/questions/70985437

            QUESTION

            Any way to capture partial screenshot with Kivy?
            Asked 2022-Jan-01 at 12:17

            I am developing an app for Android and i have this issue - after i have taken a picture with the camera, i need to crop it. But the coordinates for the rectangle i have dragged over the capturing area start from the screen's 0,0 coordinates aka touch coordinates do not match actual picture's - if i try to crop the image with these using PIL, i get a partial result. One possible solution would be to take a partial screenshot with these coordinates and get the cropped picture that way. I tried to use pyscreenshot, but then i found out that it does not work on Android. Any ideas how to capture a partial screenshot on Kivy?

            Thank you

            ...

            ANSWER

            Answered 2022-Jan-01 at 12:17

            For possible anyone with the same issue - i did not find any good way to grab a screenshot and crop selected portion out of it. I did, however, solve it this way - i move to a new screen, resize picture to device's screen resolution and from then i can crop it with touch without no issues - i did not have to find a clever way to map screen coordinates with image's. After cropping and saving i resize the image back to a fixed resolution. This is not a elegant solution, but still will serve my purpose. Thank you anyone who thought along with me.

            Source https://stackoverflow.com/questions/70524180

            QUESTION

            Regular expressions search returning "nonetype"
            Asked 2021-Jul-16 at 04:57

            Ok, so I've been trying to make a program to search between these 2 parameters: "MA(7):" and "MA(25):". I have made programs that use the re.search function in the past, but this one is stubborn and doesn't work. The code is as follows:

            ...

            ANSWER

            Answered 2021-Jul-16 at 04:57

            This is the expression I used:
            r"MA\(7\): (.*) MA\(25\):"
            You might want to remove the spaces on the ends of the pattern as that is what I did and it seemed to work fine although I did have to do token[1] to get the Hello find this part

            Source https://stackoverflow.com/questions/68403524

            QUESTION

            Python add string to array but whenever theres a blank space make a new element?
            Asked 2021-Mar-20 at 19:24
            import pyscreenshot as ImageGrab
            import cv2
            import pytesseract
            # Take picture
            im = ImageGrab.grab()
            im = ImageGrab.grab(bbox=(730, 180, 970, 400))
            # Show picture
            im.show()
            # Save picture
            im.save('C:\\Users\\eddwik26\\Desktop\\phack\\screenshot.png')
            
            # AI that reads string from picture
            pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'
            img = cv2.imread(r'C:\\Users\\eddwik26\\Desktop\\phack\\screenshot.png')
            textFromImage = pytesseract.image_to_string(img)
            formatedText = textFromImage.replace("\n\n", "  ")
            print(formatedText)
            print("\n")
            
            # Formatter
            
            
            ...

            ANSWER

            Answered 2021-Mar-20 at 19:24

            Is this what you are expecting?

            Source https://stackoverflow.com/questions/66723673

            QUESTION

            How can I freeze a desktop then draw on it? Like gyazo or sharex region selection
            Asked 2021-Feb-07 at 20:12

            I am trying to make something like this, https://gyazo.com/b2dd4329487ee9f20fe8f731fe38bc9f (This). I have no clue how to make the region selection (just the region selection). I am using kivy for the gui. This is what I have for the region selection/capture so far.

            ...

            ANSWER

            Answered 2021-Feb-07 at 20:12
                from PyQt5 import QtCore, QtGui
                from PyQt5.QtWidgets import QApplication, QWidget
                from tkinter import *
                from PIL import ImageGrab
                import numpy as np
                import cv2
                from playsound import playsound
                from pynput.keyboard import Listener
                from io import BytesIO
                import win32clipboard
                from PIL import Image
                import os
                import random
                import threading
                import json
                
                cwd = os.getcwd()
                
                def read_json(file_name):
                    with open(fr"{file_name}.json", "r") as f:
                        datajs = json.load(f)
                    return datajs
                
                def save_data(dataxl):
                    with open("config.json", "w") as jsonFile:
                        json.dump(dataxl, jsonFile)
                
                data_js = read_json('config')
                
                def random_char(y):
                    str1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
                    return ''.join(random.choice(str1) for _ in range(y))
                
                def takess():
                    img_name = random_char(10)
                    img = ImageGrab.grab()
                    img.save(f'./images/{img_name}.png')
                    img = cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB)
                
                    threading.Thread(target=lambda: playsound(rf'{cwd}\src\sound.mp3')).start()
                
                    def send_to_clipboard(clip_type, datajk):
                        win32clipboard.OpenClipboard()
                        win32clipboard.EmptyClipboard()
                        win32clipboard.SetClipboardData(clip_type, datajk)
                        win32clipboard.CloseClipboard()
                
                    image = Image.open(fr'./images/{img_name}.png')
                
                    output = BytesIO()
                    image.convert("RGB").save(output, "BMP")
                    data = output.getvalue()[14:]
                    output.close()
                
                    send_to_clipboard(win32clipboard.CF_DIB, data)
                
                    cv2.imshow('Captured Image', img)
                    cv2.waitKey(0)
                    cv2.destroyAllWindows()
                
                class QuickSnip(QWidget):
                    def __init__(self):
                        super().__init__()
                        root = Tk()
                        self.setGeometry(0, 0, root.winfo_screenwidth(), root.winfo_screenheight())
                        self.begin = QtCore.QPoint()
                        self.end = QtCore.QPoint()
                        self.setWindowOpacity(0.5)
                        QApplication.setOverrideCursor(
                            QtGui.QCursor(QtCore.Qt.CrossCursor)
                        )
                        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
                        self.show()
                
                    def paintEvent(self, event):
                        qp = QtGui.QPainter(self)
                        qp.setPen(QtGui.QPen(QtGui.QColor('dark blue'), 1))
                        qp.setBrush(QtGui.QColor(128, 128, 255, 128))
                        qp.drawRect(QtCore.QRect(self.begin, self.end))
                
                    def mousePressEvent(self, event):
                        self.begin = event.pos()
                        self.end = self.begin
                        self.update()
                
                    def mouseMoveEvent(self, event):
                        self.end = event.pos()
                        self.update()
                
                    def mouseReleaseEvent(self, event):
                        self.close()
                
                        img_name = random_char(10)
                        x1 = min(self.begin.x(), self.end.x())
                        y1 = min(self.begin.y(), self.end.y())
                        x2 = max(self.begin.x(), self.end.x())
                        y2 = max(self.begin.y(), self.end.y())
                
                        img = ImageGrab.grab(bbox=(x1, y1, x2, y2))
                        img.save(fr'{cwd}\images\{img_name}.png')
                        img = cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB)
                
                        threading.Thread(target=lambda: playsound(rf'{cwd}\src\sound.mp3')).start()
                
                        def send_to_clipboard(clip_type, datajk):
                            win32clipboard.OpenClipboard()
                            win32clipboard.EmptyClipboard()
                            win32clipboard.SetClipboardData(clip_type, datajk)
                            win32clipboard.CloseClipboard()
                
                        image = Image.open(fr'{cwd}\images\{img_name}.png')
                
                        output = BytesIO()
                        image.convert("RGB").save(output, "BMP")
                        data = output.getvalue()[14:]
                        output.close()
                
                        send_to_clipboard(win32clipboard.CF_DIB, data)
                
                        cv2.imshow('Captured Image', img)
                        cv2.waitKey(0)
                        cv2.destroyAllWindows()
                
                def on_press(key):
                    if str(key) == f"'{data_js['hotkey']}'" or str(key) == f"Key.{data_js['hotkey']}":
                        app = QApplication([])
                        window = QuickSnip()
                        window.show()
                        app.exec()
                
                    elif str(key) == 'Key.print_screen':
                        takess()
                
                def main_func():
                    with Listener(
                            on_press=on_press) as listener:
                        listener.join()
            

            Source https://stackoverflow.com/questions/65963852

            QUESTION

            ModuleNotFoundError: No module named 'flake8'
            Asked 2020-Dec-15 at 20:12

            here is the part of the files that are important for this question:

            ...

            ANSWER

            Answered 2020-Jul-21 at 20:31

            My compliments on such an extensive report. Your issue lies probably in this weird setup you've got going on.

            Source https://stackoverflow.com/questions/62667763

            QUESTION

            Taking screenshot of a specific space using python
            Asked 2020-Aug-31 at 06:36

            I am trying to take a screenshot of a specific region using python.

            I wrote this code:

            ...

            ANSWER

            Answered 2020-Aug-31 at 06:20

            I made a code for you. It works fine in my side. Please let me know your opinion after running my code.

            Source https://stackoverflow.com/questions/63665517

            QUESTION

            Why can't I install these specific requirements?
            Asked 2020-Jul-03 at 23:28

            I'm trying to create a conda environment, but it has many dependencies that anaconda seems unable to locate, always sending the same error message below:

            ...

            ANSWER

            Answered 2020-Jul-03 at 23:14

            py-opencv-3.4.2-py37h7c891bd_1 is osx-64 based build and you're trying to install into Windows OS. It's good to find the same build for Windows from the link you shared. Otherwise, just use the version without a build number. e.g. env.yml for you.

            Source https://stackoverflow.com/questions/62723122

            QUESTION

            pyscreenshot.err.FailedBackendError: All backends failed
            Asked 2020-Jun-16 at 12:19

            I am a newbie to python web apps.

            I'm using pythonanywhere to host my webapp. Pyscreenshot is installed via pip3.8 install --user Pillow pyscreenshot

            I am using ajax to call a function on button click which uses pyscreenshot to take screenshot of the screen and store it as an image file on given path.

            Everything runs fine on local environment (manjaro, python3.8)

            However when I run the same code on pythonanywhere, I get an unhandled exception on the site. In the error logs I see the following:

            ...

            ANSWER

            Answered 2020-Jun-16 at 12:19

            PyScreenshot is for taking screenshots of desktop applications. Since your application is running on a server, there's nothing to take a screenshot of.

            If you intended to take a screenshot of the user's browser, you would use frontend tooling, which runs in the browser, not a server-side tool.

            Source https://stackoverflow.com/questions/62407785

            QUESTION

            Python script runs fine from terminal but crashes when run from crontab
            Asked 2020-May-22 at 15:05

            I have a simple python script that takes screenshots of a computer that is running Ubuntu. I want it to run automatically on startup, so I put @reboot python3 /bin/program.py in the non-sudo version of crontab.

            The program works fine when run from terminal, but gives the error pyscreenshot.err.FailedBackendError. I put it in a try loop, and had it write all exceptions to a file, and that's how I found the error message, "All backends failed."

            It has something to do with the program 'pyscreenshot' not working correctly.

            ...

            ANSWER

            Answered 2020-May-22 at 15:05

            If the user that the cron job runs as is also logged in on the console (you mention a reboot, so I'm guessing that you have enabled autologin), then your cron job might work if you also add:

            Source https://stackoverflow.com/questions/61954338

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pyscreenshot

            You can install using 'pip install pyscreenshot' or download it from GitHub, PyPI.
            You can use pyscreenshot like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install pyscreenshot

          • CLONE
          • HTTPS

            https://github.com/ponty/pyscreenshot.git

          • CLI

            gh repo clone ponty/pyscreenshot

          • sshUrl

            git@github.com:ponty/pyscreenshot.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link