Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python take a screenshot

import pyautogui

myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'Path to save screenshotfile name.png')
Comment

How to take a screenshot using python

import pyautogui
screenshot = pyautogui.screenshot()
screenshot.save("FilePathwhereyouwantToSaveFileName.FileFormat")
Comment

python create and show screenshot

import numpy as np
import pyautogui
import scipy.ndimage
import pygame


class Viewer:
    def __init__(self, display_size):
        pygame.init()
        self.display = pygame.display.set_mode(display_size)
        self.pic = np.zeros((*display_size, 3), dtype=np.uint8)

    def set_title(self, title):
        pygame.display.set_caption(title)

    def set_image(self, image):
        self.pic = image

    def start(self):
        running = True
        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    running = False

            surf = pygame.surfarray.make_surface(self.pic)
            self.display.blit(surf, (0, 0))

            pygame.display.update()

        pygame.quit()


viewer = Viewer((700, 700))

screen_size = pyautogui.size()

img = pyautogui.screenshot()
img = np.array(img)
img = np.rot90(img)
img = np.flipud(img)
background = np.zeros((700, 700, 3), dtype=np.uint8)
img = scipy.ndimage.zoom(img, (min(700 / img.shape[0], 700 / img.shape[1]),
                               min(700 / img.shape[0], 700 / img.shape[1]), 1))
# blend the image with the background
background[int(350 - img.shape[0] / 2):int(350 + img.shape[0] / 2),
           int(350 - img.shape[1] / 2):int(350 + img.shape[1] / 2), :] = img
viewer.set_image(background)
viewer.start()
Comment

fastest way to take screenshot python

import mss
import numpy as np

with mss.mss() as sct:
    monitor = {"top": 160, "left": 160, "width": 160, "height": 135}
    img_array = np.array(sct.grab(monitor))
    # Do whatever you want...
Comment

take screenshot of website python

Mac: webkit2png 
Linux+KDE: khtml2png. 
Windows: webscreenshot
Comment

how to take screenshot with python


import pyautogui
im2 = pyautogui.screenshot('my_screenshot.png', region=(x,y, width, height))
Comment

PREVIOUS NEXT
Code Example
Python :: how to remove stopwords from a string in python 
Python :: python join list with comma 
Python :: python check if number is complex 
Python :: how to make an encryption program in python 
Python :: insert column at specific position in pandas dataframe 
Python :: Import "django.core.urlresolvers" could not be resolved 
Python :: Pandas bins pd.cut() 
Python :: pyinstaller for spacy code 
Python :: how to make a pairs plot with pandas 
Python :: making a python code without python 
Python :: most occurring string in column pandas 
Python :: how to recurse a function 
Python :: per gjera te shumta. Python 
Python :: df reanme columns 
Python :: pandast change datetime to date 
Python :: python similar strings 
Python :: scroll to bottom in selenium python 
Python :: print the heat map python 
Python :: python prayer time 
Python :: pandas dataframe from multiple csv 
Python :: how to move file from one location to another with python 
Python :: replace column values pandas 
Python :: sort by column dataframe pyspark 
Python :: python check if string starting with substring from list ltrim python 
Python :: django templateview 
Python :: factors addition in pyhone 
Python :: python one line return 
Python :: streamlit button to load a file 
Python :: dataframe unique values in each column 
Python :: find matches between two lists python 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =