An image editor with an API (preferably python-oriented)
Is there an image editor for OS X (e.g. Preview) that can be operated programmatically, preferably with python, or that has a built-in programming language, like MS Word has VBA built-in (at least on Windows systems)?
I'd like to be able to do the following with code:
- Open an image in the image editor,
- Use the editor to save the image to some arbitrary location in the file system.
It is essential for me to save the file via the editor, since when the editor saves a file it does more than simply save it: it also writes meta info, which I am interested in.
macOS Sierra Version 10.12.4
Preview supports AppleScript which allows you to open and save files from CLI. There are commands for open and save.
For example, to open a file with Preview:
tell application "Preview"
open "/path/to/file.png"
end tell
You can run AppleScript as a script file, or from the command line using osascript -e "…"
.
osascript -e "tell application \"Preview\"" -e "open \"/path/to/file.png\"" -e "end tell"
You can find the full Preview AppleScript dictionary by opening Script Editor.app (from the Utilities folder), choosing File → Open Dictionary and selecting Preview. This will show you many of the commands that Preview supports with the syntax for how to use them.
You can edit image files with Imagemagick cli.
This doesn't present a GUI, but rather provide commands for working with image files directly. There are a plethora of features to support complex editing.
You can install this using Homebrew:
brew install imagemagick
For a full list of functionality, see imagemagick.org or python.org ImageMagick wiki