How to process images using an iOS or macOS Shortcut
Last updated
Last updated
Apple Shortcuts is an app that comes built-in with recent versions of iOS and macOS, and that provides users with a no-code editor to create and execute workflows.
Because Shortcurts support making HTTP calls, you can implement a Shortcut that integrates with the Photoroom API.
And with such a Shortcut, it becomes possible to easily process a batch of images through the Photoroom API directly from inside the Finder, Files or Photos app:
We actually took care of implementing such a Shortcut, you can download it here.
The Shortcut needs to be configured with an API Key in order to be functionnal.
The instructions on how to do it are available just below on this page.
If you open the Shortcut, you will see that this is the workflow that it contains:
This workflow can be broken down into 4 main steps that we're going to explore in more details.
The Shortcut has been configured so that it's very easy to invoke.
It can be invoked from two places:
through the Quick Actions menu, as demonstrated in the demo at the beginning of the page. This is the recommended way to invoke the Shortcut in macOS.
The next step takes care of automatically converting the images to JPEG, to make sure that they are in a format that is compatible with the Photoroom API.
This step is important, because pictures taken with an iOS device are by default saved using the .heic
format, which is not supported by the Image Editing API.
After that, the following step is to actually call the Photoroom API:
In this example the Shortcut is calling the Image Editing API, but it would of course possible to call the Remove Background API instead.
Here, make sure that you replace the placeholder REPLACE_WITH_YOUR_API_KEY with your actual API Key:
If you don't have an API Key, here are the steps to create yours.
The image and the set of edits that will be applied to it are passed inside of the Request Body:
In this example, the Image Editing API will:
remove the background to isolate the main subject of the image
center it inside a square of 1000x1000 pixels, with 5% of padding and a transparent background
add a realistic shadow that simulates a soft lighting
You can of course modify the parameters of the call to update the edits that will be applied to the image in order to match your own requirements and brand guidelines.
More details about the list of available edits are available in the documentation of the Image Editing API.
Finally, the last step is to save the processed images that have been returned by the Photoroom API.
For this, we simply ask the user to select the directory where the result images should be saved:
In this tutorial, we've covered how it's possible in iOS and macOS to easily process a batch of th Photoroom API in iOS or macOS by using an Apple Shortcut.
If you want to give it a try, don't forget that the Shortcut we've covered can be downloaded here.
from the Share Sheet, which is usually accessible by tapping this button . This is the recommended way to invoke the Shortcut in iOS.