macOS automation to quickly resize images and convert to webp
-
macOS with Automator
-
node
brew install node
-
sharp image processor
npm i sharp -g
Simply select any image file(s) and launch with a custom keyboard shortcut or through the Quick Actions menu:
This is the simplest automation. With a single keyboard shortcut (we use ⌘ + ^ + W
), all selected images will be converted to the .webp
format and stored alongside the original image.
This automation will optionally resize the image. There are three use cases:
-
If no width is entered, the automation falls back to
convert-images
and converts but does not resize the images. -
If a width—but not a height—is entered, the image is resized to the selected width. The height is automatically calculated based on the aspect ratio of the original image.
In the gif at the top of this page, the height is not entered and the dimensions of the image scale from 6000x4000 to 2000x1333.
- If a width and a height are entered, the image is scaled according to the object-fit: cover directive in CSS.
See our tutorial video.
-
Install node and sharp on your machine
brew install node
npm i sharp -g
-
Open Automator and make a new Quick Action
- Change the
Workflow receives current
properties toimages files
andFinder
.
- Add a
Set Value of Variable
step. Create a new variable and name it "files".
- Add a
Run AppleScript
step. Paste in the contents ofconvert-images/convert-images.scpt
.
-
Name and save your Automation (e.g., "ConvertImages")
-
Place the
convert-images/convert-images.js
file in your/Users/<name>/
folder.
Your automation should now appear in the Quick Actions menu!
- [Optional]: Map this to a keyboard shortcut by going to
System Settings > Keyboard > Keyboard Shortcuts > Services
and giving it a unique keyboard shortcut.
Now you can convert images simply by selecting them and clicking ⌘ + ^ + W
!
Repeat the above steps with these changes:
-
Add a
Run AppleScript
step. Paste in the contents ofconvert-resize-images/convert-resize-images.scpt
. -
Name and save your Automation (e.g., "ConvertResizeImages")
-
Place the
convert-images/convert-resize-images.js
file in your/Users/<name>/
folder.
I use a keyboard shortcut of ⌘ + ^ + R
for this automation.