Automate image size in Preview

I do a lot of publishing of image heavy books, and the best size for my images in this process is 2048px wide at 72dpi. So I load the original image into Preview and use Tools/Image Size... to set these parameters, but for hundreds of images in each publication I'd like to automate this.


I would like to assign a hot key to use when the image is open in Preview that would select the menu choice and then enter "2048" - tab - tab- "72" - enter.


Can a shortcut do this, or applescript, or some third party keyboard recorder?


Thanks in advance.

Mac Studio

Posted on Mar 7, 2025 9:54 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 7, 2025 11:36 AM

The AppleScript dictionary for Preview is just abysmal and won't give you access to the image size panel in the application. It may be more straightforward to use Apple's scriptable image processing system (sips) to achieve this image manipulation goal. In the Terminal:

/usr/bin/sips -s format jpeg -s formatOptions 100 --resampleWidth 2048 -s dpiWidth 72.0 -s dpiHeight 72.0 --out newImg.jpg inImg.jpg


As an example, my portrait inImg.jpg has dimensions 3888 x 5184 and is a 300 DPI image. When I run the preceding sips command line above on it, the output newImg.jpg is 1365 x 2048 and 72 DPI. The sips utility does not work on camera RAW images.


I have a working Shortcuts Quick Action that takes one or more selected non-RAW images in the Finder and outputs the above settings with a filename of originalname_2048_72.ext. The original image is untouched.


I have only tested this Shortcut in macOS Sequoia v15.3.1. When you click that link, Shortcuts will offer to install the Shortcut for you. I have named it: Resample Image to 2048 px. You can edit it by right-clicking on the Shortcut and choosing Edit…



The sips(1) man page can be opened from your browser in a separate Terminal window with:

x-man-page://sips


or from the Terminal with the following command sequence:

mandoc -Tpdf -mdoc $(man -w sips) | open -f -a Preview



10 replies
Question marked as Top-ranking reply

Mar 7, 2025 11:36 AM in response to Rocky Rakoon

The AppleScript dictionary for Preview is just abysmal and won't give you access to the image size panel in the application. It may be more straightforward to use Apple's scriptable image processing system (sips) to achieve this image manipulation goal. In the Terminal:

/usr/bin/sips -s format jpeg -s formatOptions 100 --resampleWidth 2048 -s dpiWidth 72.0 -s dpiHeight 72.0 --out newImg.jpg inImg.jpg


As an example, my portrait inImg.jpg has dimensions 3888 x 5184 and is a 300 DPI image. When I run the preceding sips command line above on it, the output newImg.jpg is 1365 x 2048 and 72 DPI. The sips utility does not work on camera RAW images.


I have a working Shortcuts Quick Action that takes one or more selected non-RAW images in the Finder and outputs the above settings with a filename of originalname_2048_72.ext. The original image is untouched.


I have only tested this Shortcut in macOS Sequoia v15.3.1. When you click that link, Shortcuts will offer to install the Shortcut for you. I have named it: Resample Image to 2048 px. You can edit it by right-clicking on the Shortcut and choosing Edit…



The sips(1) man page can be opened from your browser in a separate Terminal window with:

x-man-page://sips


or from the Terminal with the following command sequence:

mandoc -Tpdf -mdoc $(man -w sips) | open -f -a Preview



Mar 8, 2025 2:02 AM in response to Rocky Rakoon

You can edit the Shortcut that I provided and omit the --out content. The "${f}" is the given input image.


Sips will just overwrite the input JPG with your preferred changes. Optionally, and for organizational purposes, you might put the original images in a folder named 2048_72, select all of the images in that folder, and run the Shortcut on them en masse.

Mar 12, 2025 3:03 PM in response to Rocky Rakoon

The assumption is that you are using the Quick Action with existing JPG images that you intend to overwrite with JPG data per the SIPS changes. It will explode if you start with a camera RAW image (e.g. CR3, NEF, ARW, etc), or a non-JPG raster image as SIPS cannot overwrite a non-JPG image with designated JPG content. This would work using the --out syntax as I have successfully used a camera RAW source file and used a --out JPG result file.

Mar 12, 2025 9:25 AM in response to Rocky Rakoon

Well, I'm at a loss. I've tried to delete various elements of "--out content" to no avail. I kept getting errors. So I deleted the shortcut and re-imported the original you created and now I can't even get that to run, getting an error that says "Cannot extract image from file. Error 13: an unknown error occurred." I'm at a loss, but very appreciative of your trying to help, Viking. I guess I'll just keep using the menu item in Preview and manually change the dimensions of the image.


Rock

Mar 12, 2025 7:45 PM in response to VikingOSX

I fully understand, Sir, and you've made that clear. All I've tried to use the shortcut on are jpg files, and I don't understand why it's not working for me. FYI, when I first installed the original script you sent (installed as a quick action) it worked as advertised...writing out a new file with the intended dimensions and with the appended title to keep the original safe. Now even that original shortcut will not do what it originally did, and any attempt to execute the original shortcut or the newer ones result in the same error.


I just ain't smart enough to know why this is. But I do so appreciate your help here, Viking. Go figure??


Rock

Mar 7, 2025 7:47 PM in response to VikingOSX

Viking, you have been incredibly generous with your time to help me here. I have installed this shortcut and it works just as advertised. And I understand that leaving the original file is important in most instances, but I want to do this on a regular basis and I always have another copy of the original. So I'd be fine with having it change the original and not save out a new file with the _2048_72 appended... So could just edit and delete the script from --out through f}" ? I'm just trying to save the action of removing the appended title and deleting the original file.


Thank you!


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automate image size in Preview

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.