Question about batch converting PNG images to a size I want
May 6, 2019 1:28 AM   Subscribe

I have a folder of 800 images that I'd like to get down to a range of about 500K - 1 MB (so that they will show up nicely in an app.) The trouble is, their sizes vary wildly. Is there a good way to aim for a desired file size range, rather than just setting a quality level?

I've been using ImageMagick and trying out different quality levels.

The files in question have these filesizes that are all over the map, from 17 MB down to 110 Kb (!). My crude solution so far has been to divide them into buckets, based on size range. In the little bucket go the ones that should not suffer further lossiness. In the medium bucket go the ones that are just A-OK as they are. There's another bucket for big ones that could stand to be cut down a little using 90% quality level. and a final bucket for the monster-sized ones that need a huge chunk of size chopped out.

It's not that precise though and I wonder if there is a better solution, where you can somehow aim for a range of JPG (or PNG) filesize, and let your tools decide on the best way to get there for each file? Any help much appreciated.
posted by johngoren to Computers & Internet (3 answers total) 3 users marked this as a favorite
 
Oh and to clarify, I'm converting them for now to JPG and have already tried PNG crush tools.
posted by johngoren at 1:30 AM on May 6, 2019


You can use 'convert' from imagemagick to render them into a combination of maximum dimensions (or shrink) and filesize. You can use just the filesize option (-define jpeg:extent=nnnKB) if you want to keep the dimensions the same as the originals.
posted by rhizome at 1:45 AM on May 6, 2019 [3 favorites]


This is awesome, thanks! I'm sitting back and watching it brew a perfect folder of 750 kb images as sure as watching coffee drip into a mug. Preciate it.
posted by johngoren at 4:51 AM on May 6, 2019 [1 favorite]


« Older Cheap visit to California?   |   What low-carb foods have a satisfying chewy... Newer »
This thread is closed to new comments.