Python wrapper around Apple Photos applescript interface
Project description
PhotoScript
What is PhotoScript
PhotoScript provides a python wrapper around Apple Photos applescript interface. With PhotoScript you can interact with Photos using python. Runs only on MacOS. Tested on MacOS Catalina.
PhotosScript is limited by Photos' very limited AppleScript dictionary.
Installation
PhotoScript uses setuptools, thus simply run:
python3 setup.py install
Or you can install via pip:
pip install photoscript
Example
""" Simple example showing use of photoscript """
import photoscript
photoslib = photoscript.PhotosLibrary()
photoslib.activate()
print(f"Running Photos version: {photoslib.version}")
album = photoslib.album("Album1")
photos = album.photos()
for photo in photos:
print(f"{photo.title}, {photo.description}, {photo.keywords}")
new_album = photoslib.create_album("New Album")
photoslib.import_photos(["/Users/rhet/Downloads/test.jpeg"], album=new_album)
photoslib.quit()
Documentation
Full documentation here.
Additional documentation about Photos and AppleScript available on the wiki.
Limitations
Photos' AppleScript interface is very limited. For example, it cannot access information on faces in photos nor can it delete a photo. PhotoScript is thus limited. PhotoScript works by executing AppleScript through an Objective-C bridge from python. Every method call has to do a python->Objective C->AppleScript round trip; this makes the interface much slower than native python code. This is particularly noticeable when dealing with Folders which requires significant work arounds.
Where possible, PhotoScript attempts to provide work-arounds to Photos' limitations. For example, Photos does not provide a way to remove a photo from an album. PhotoScript does provide a Album.remove()
method but in order to do this, it creates a new album with the same name as the original, copies all but the removed photos to the new album then deletes the original album. This simulates removing photos and produces the desired effect but is not the same thing as removing a photo from an album.
Related Projects
- osxphotos: Python package that provides read-only access to the Photos library including all associated metadata.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for photoscript-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab96f40a7bb5b6d2e70745445cd9d4fa9a93bc363900364c102119d6db6955b7 |
|
MD5 | 25ca07946c3ed758e4fbc92f81aed6c9 |
|
BLAKE2b-256 | ec7b6ff07506aeec1f61a175d5f86e293f475410eca2a852bb733f24932a858e |