Skip to content

MacOS automation to quickly resize images and convert to webp

Notifications You must be signed in to change notification settings

cedar-studios/webp-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webp-automation

macOS automation to quickly resize images and convert to webp

short demonstration

Requirements

  • macOS with Automator

  • node

      brew install node
    
  • sharp image processor

      npm i sharp -g
    

Usage

Simply select any image file(s) and launch with a custom keyboard shortcut or through the Quick Actions menu:

quick actions menu

convert-images

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.

convert-resize-images

This automation will optionally resize the image. There are three use cases:

  1. If no width is entered, the automation falls back to convert-images and converts but does not resize the images.

  2. 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.

  1. If a width and a height are entered, the image is scaled according to the object-fit: cover directive in CSS.

Installation

See our tutorial video.

convert-images

  1. Install node and sharp on your machine

    brew install node

    npm i sharp -g

  2. Open Automator and make a new Quick Action

automator quick action

  1. Change the Workflow receives current properties to images files and Finder.

automator workflow input

  1. Add a Set Value of Variable step. Create a new variable and name it "files".

automator set variable

  1. Add a Run AppleScript step. Paste in the contents of convert-images/convert-images.scpt.

automator apple script

  1. Name and save your Automation (e.g., "ConvertImages")

  2. Place the convert-images/convert-images.js file in your /Users/<name>/ folder.

Your automation should now appear in the Quick Actions menu!

  1. [Optional]: Map this to a keyboard shortcut by going to System Settings > Keyboard > Keyboard Shortcuts > Services and giving it a unique keyboard shortcut.

keyboard shortcuts

keyboard services

Now you can convert images simply by selecting them and clicking ⌘ + ^ + W !

convert-resize-images

Repeat the above steps with these changes:

  1. Add a Run AppleScript step. Paste in the contents of convert-resize-images/convert-resize-images.scpt.

  2. Name and save your Automation (e.g., "ConvertResizeImages")

  3. Place the convert-images/convert-resize-images.js file in your /Users/<name>/ folder.

I use a keyboard shortcut of ⌘ + ^ + R for this automation.

About

MacOS automation to quickly resize images and convert to webp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published