Resize Images to File Size? Need to do it a lot!

Hi Team! :slight_smile:

I find myself needing to resize images to allow for arbitrary file sizes allowed by some websites. For example, I may take photos that are of resolution X and come out to be 13MB. I need to resize it to be 5MB or less to be allowed on a certain website per their demands.

My workflow is to open the file in Preview, click resize, and then manually “guess” on a size that seems like it would be smaller and iteratively adjust until I hit the size. In preview, it does show what the final file size will be, based on what adjustments to resolution I make, but it only lets me adjust resolution and guess what I need. This is a big waste of time as you can imagine if I have 20+ images to do!

Is there any app that lets me resize an image to be a certain file size and the app calculates the maximum resolution allowed to fall under that size?

Thanks so much!

I’m unaware of any apps, but maybe there are.

Take a look at “ImageMagick” which is a command line program that you can install on your Mac. Search for “ImageMagick mac” to get started. Years ago I used it to do a batch image resize on thousands of photos. Free of charge.

I recall that Adobe’s Lightroom allowed to export images setting a file size upper limit, but it might be a little costly for your needs.

You can batch resize in preview anyway, so you could speed up your workflow without any new app (the article is a little old, but should work nowadays too).

2 Likes

With ImageMagick, the command would be something like “convert input.jpg -define jpeg:extent=5000kb output.jpg”

2 Likes

Yep. And before doing this, one must see what it is, install (or confirm already installed) the program, do a little reading of the manual or man file, experiment, etc. Which is why I pointed to how to get started…

But thanks for pointing out the simple command line to do it. Had it occured to me I would have done that!! :grinning:

FYI, the ImageMagick solution posted by @Lars does not resize the image geometrically, as @GlitterPony’s “by hand” method does. If input.jpg is 4032x3024 pixels, output.jpg will have those same dimensions. It achieves the file size reduction by increasing the JPEG compression. I think the results look good, but you should know what’s happening before applying it to dozens of images.

Here’s the documentation for -define.

If you have a Setapp subscription, you could try using Photobulk.

For a similar need, i created a simple automator script that resizes an image by 50%. The script runs in the finder (right click, select services) so its right where you need it. If the result is still to big, run script again.

image

So nothing to purchase, nothing new to learn…

3 Likes

Retrobatch may come close, allows to set size, and dpi as well as a lot more and shows the projected results.

For bulk image processing its a huge time saver.

Adobe Photoshop Elements will do that. I’m still using Ver.6 from 2009 with Mojave. Pixelmator will also do it.

Coincidently, today (in all this idle time I now have) I ran across the program which I believe is installed on all Mac’s, the “sips” command. You can run it from a terminal. Type “man sips” to read the manual instructions. Search internet for other guidance. Using “sips jpeg resize” I found https://lifehacker.com/batch-resize-images-quickly-in-the-os-x-terminal-5962420, but there are more.

I haven’t tested or played with it, so you should.

I guess, so far, finding “sips” is my learning of the day.

Resizing to particular dimensions is fairly easy - you can even resize by percentage in Preview, and batch-processor with a simple Automator action.

Resizing to a specific file size is very difficult, and I don’t know of any Mac apps that do that.

I have an Automator action that uses AppleScript and Sips to resize images. Here’s a collapsed view of the action

:

  1. The action takes in image files.
  2. Copies those image files to a new folder.
  3. Renames those image files.
  4. Runs the AppleScript to resize the files using Sips.
  5. Selects the image files.
  6. Imports the resized files into Photos.

Here’s the complete Applescript:

on run {input, parameters}
	
	repeat with everyDrop in input
		set originalFile to quoted form of POSIX path of (everyDrop as text)
		tell application "Finder"
			set originalName to everyDrop's name
			set imageContainer to (everyDrop's container as text)
		end tell
		
		set reSizedName to "1080W" & originalName
		set outputPath to quoted form of POSIX path of (imageContainer & originalName)
		
		do shell script "sips --resampleWidth 1080 " & originalFile & " --out " & outputPath
	end repeat
	
	return input
end run