# 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.)
Raw data
{
"_id": null,
"home_page": "https://github.com/asweigart/pyperclipimg",
"name": "pyperclipimg",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Al Sweigart",
"author_email": "al@inventwithpython.com",
"download_url": "https://files.pythonhosted.org/packages/6f/85/5afb0c0007fed16e581ef97d2ff44a4633dba6609b584256a88657ca6f3c/pyperclipimg-0.2.0.tar.gz",
"platform": null,
"description": "# pyperclipimg\r\nPython copy() and paste() clipboard functions for images on Windows, macOS, and Linux.\r\n\r\nThis module has Pillow as a dependency, as well as the following dependencies:\r\n\r\nWindows: The pywin32 Python package. Install with `pip install pywin32`\r\n\r\nmacOS: The pyobjc-framework-quartz Python package. Install with `pip install pyobjc-framework-quartz`\r\n\r\nLinux: Either the xclip or wl-copy commands. Install these with `sudo apt install xclip` or `sudo apt install wl-clipboard`\r\n\r\n# Quickstart\r\n\r\nTo 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)\r\n\r\n>>> import pyperclipimg as pci\r\n>>> pci.copy('example.png') # Copy by filename.\r\n\r\n>>> import pyperclip as pci\r\n>>> from pathlib import Path\r\n>>> pci.copy(Path('example.png')) # Copy by Path object.\r\n\r\n>>> import pyperclip as pci\r\n>>> from PIL import Image\r\n>>> pci.copy(Image.open('example.png')) # Copy by Image object.\r\n\r\nTo 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.\r\n\r\n>>> import pyperclipimg as pci\r\n>>> im = pci.paste() # Get the clipboard image as an Image object.\r\n>>> im.show() # Display the image on the screen.\r\n\r\nThe `paste()` function depends entirely on Pillow's `ImageGrab.grabclipboard()` function.\r\n\r\nPyperclipimg also has `show()` and `save()` functions as a convennient shortcut for the Pillow functions of the same name:\r\n\r\n>>> import pyperclipimg as pci\r\n>>> pci.show() # Display the clipboard's image on the screen.\r\n>>> pci.paste().show() # (Also displays the clipboard's image on the screen.)\r\n\r\n>>> import pyperclipimg as pci\r\n>>> pci.save() # Saves the clipboard's image with a name like clipboard-2024-12-17_11-10-51-412737.png.\r\n>>> pci.save('foo.png') # Saves the clipboard's image named foo.png.\r\n>>> pci.save('some_folder') # Saves the clipboard's image with a name like some_folder/clipboard-2024-12-17_11-10-51-412737.png.\r\n\r\n\r\nThis 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.)\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Cross-platform copy() and paste() Python functions for images.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/asweigart/pyperclipimg"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6f855afb0c0007fed16e581ef97d2ff44a4633dba6609b584256a88657ca6f3c",
"md5": "2f7c312da172f6ea57825456d80983c5",
"sha256": "7934402ed7ce898e0a3b659e8cafb7c6a2faf7f9ad00069a0fe15a077aae1239"
},
"downloads": -1,
"filename": "pyperclipimg-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "2f7c312da172f6ea57825456d80983c5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5365,
"upload_time": "2024-12-17T16:35:39",
"upload_time_iso_8601": "2024-12-17T16:35:39.006952Z",
"url": "https://files.pythonhosted.org/packages/6f/85/5afb0c0007fed16e581ef97d2ff44a4633dba6609b584256a88657ca6f3c/pyperclipimg-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-17 16:35:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "asweigart",
"github_project": "pyperclipimg",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyperclipimg"
}