Integrating Zipic
Zipic supports URL Scheme, enabling both scripts and other apps to leverage Zipic’s full image compression capabilities.
URL Scheme
Zipic’s URL Scheme is: zipic://compress
.
URL parameters can specify the objects to be compressed and compression options.
Specifying Compression Targets
You can specify multiple targets, including both image paths and directory paths.
Specifying Compression Options Pro Only
Compression Level
The higher the level, the greater the compression and the lower the quality. Generally, levels 2 or 3 provide a good balance between quality and size, but results may vary depending on the format.
Parameter: level
, double precision
Range: 1~6, step: 1.0
Save Directory
Parameter: directory
, path to save the files, string
To specify a save directory, use the location
option set to custom
.
Parameter: location
, string, options:
original
custom
To save files to the default directory, you must enable the specified
option and set it to true
.
Parameter: specified
, boolean, default value: false
true
false
Format Conversion
Parameter: format
, string
Specifies the desired output format.
Options:
original
jpeg
webp
heic
avif
Resize Image
Parameter: width
, double
Sets the desired width, default is 0
, which auto-adjusts.
Parameter: height
, double
Sets the desired height, default is 0
, which auto-adjusts.
Resize the image to 1920 pixels wide, maintaining the original aspect ratio.
Example Usage
Using Terminal
To compress the image /Users/5km/Downloads/CleanshotX/demo.png
, convert it to webp
format, and save it to the Downloads directory, use the following URL Scheme:
You can execute this URL Scheme in the terminal using the macOS open
command:
The video below demonstrates the process in iTerm2, where the image is successfully compressed and saved in webp
format in the Downloads directory.
Shortcuts
Using macOS Shortcuts and the Zipic URL Scheme, you can quickly compress selected images or directories in Finder. Below is the complete configuration for the Zipic shortcut:
Here’s a step-by-step explanation:
- Obtain the list of selected files in Finder.
- Parse the selected files into a list of file paths and store them in the
paths
variable. - Encode each item in
paths
asurl=ITEM
and save it to theurls
list. - Concatenate each
url
in theurls
list with&
to form the URL parameters. - Combine
zipic://compress?
with the URL params to create the final URL. - Open the final URL to trigger Zipic’s image compression.
After downloading the shortcut, import it into Shortcuts and enable it for Finder with a custom keyboard shortcut to quickly compress selected images and directories.
Programmatic Access
You can invoke Zipic’s compression capabilities from any programming language that supports URL handling. Here are examples in different languages, based on the target used in the Terminal:
We’ve implemented a Raycast extension using this URL Scheme, allowing Raycast users to quickly compress images directly from Finder. Check out the Raycast Extension Guide for more details.
For developers, we’re planning to release a VS Code extension for in-project image compression—stay tuned.