Skip to main content

pyperclipimg

Python copy() and paste() clipboard functions for images on Windows, macOS, and Linux.

This module has Pillow as a dependency, as well as the following dependencies:

Windows: The pywin32 Python package. Install with pip install pywin32

macOS: The pyobjc-framework-quartz Python package. Install with pip install pyobjc-framework-quartz

Linux: Either the xclip or wl-copy commands. Install these with sudo apt install xclip or sudo apt install wl-clipboard

Quickstart

To copy an image in a file to the clipboard, pass the filename as a str or Path object to copy(). A Pillow Image object can also be passed. Any image format that Pillow supports can be used (png, jpg, gif, bmp, webp)

import pyperclipimg as pci pci.copy('example.png') # Copy by filename.

import pyperclip as pci from pathlib import Path pci.copy(Path('example.png')) # Copy by Path object.

import pyperclip as pci from PIL import Image pci.copy(Image.open('example.png')) # Copy by Image object.

To paste the image (that is, get the image from the clipboard), call paste(). The image on the clipboard is returned as a Pillow Image object.

import pyperclipimg as pci im = pci.paste() # Get the clipboard image as an Image object. im.show() # Display the image on the screen.

The paste() function depends entirely on Pillow's ImageGrab.grabclipboard() function.

Pyperclipimg also has show() and save() functions as a convennient shortcut for the Pillow functions of the same name:

import pyperclipimg as pci pci.show() # Display the clipboard's image on the screen. pci.paste().show() # (Also displays the clipboard's image on the screen.)

import pyperclipimg as pci pci.save() # Saves the clipboard's image with a name like clipboard-2024-12-17_11-10-51-412737.png. pci.save('foo.png') # Saves the clipboard's image named foo.png. pci.save('some_folder') # Saves the clipboard's image with a name like some_folder/clipboard-2024-12-17_11-10-51-412737.png.

This module is by Al Sweigart, the creator of pyperclip which copies and pastes text to the clipboard. This module is separate because it has some heavy dependencies (pywin32, Quartz, etc.)

Metadata

Release files for pyperclipimg 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyperclipimg 0.2.0
File Size Uploaded
pyperclipimg-0.2.0.tar.gz 5.4 kB Details

Release files / pyperclipimg-0.2.0.tar.gz

Download URL pyperclipimg-0.2.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7934402ed7ce898e0a3b659e8cafb7c6a2faf7f9ad00069a0fe15a077aae1239
BLAKE2b-256 checksum
How to use checksums
6f855afb0c0007fed16e581ef97d2ff44a4633dba6609b584256a88657ca6f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0a5

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page