5

I'm currently dealing with a few applications that impose a 2mb limit on import file/image size. Currently, the only way I have found to deal with this is to manually find all images that are above 2mb, open them in preview, resize them to a certain percentage, and hope that the file size drops below 2mb (and if not, keep reducing).

This seems extraordinarily complicated. Is there an OS X application that will take an image file and reduce it to a desired file size?

5
  • 1
    What image formats do you need it to work on? Jun 11, 2014 at 5:41
  • And does it have to be an OS X specific app with graphical interface, or would a cross-platform command line tool be fine as well?
    – Izzy
    Jun 11, 2014 at 6:31
  • @NickWilde 99% of the image formats are either .jpg or .png. Jun 11, 2014 at 15:27
  • @Izzy a graphical interface is not necessary Jun 11, 2014 at 15:27
  • OK, in this case I guess I have the perfect tool for you – see my answer :)
    – Izzy
    Jun 11, 2014 at 16:05

1 Answer 1

8

I'm using ImageMagick for this kind of task, usually approaching it via compression/quality or resolution. Example:

mogrify -resize 800x600 -quality 70

But according to the list of command line options, an approach better matching your requirements is using the jpeg:extent=value parameter (e.g. -define jpeg:extent=2048KB). This will work via compression/quality alone, not reducing the resolution (if I understood the documentation correctly; I've never played with this option. You are free to combine it with -resize, though).

Restrict the maximum JPEG file size, for example -define jpeg:extent=400KB. The JPEG encoder will search for the highest compression quality level that results in an output file that does not exceed the value. The -quality option is ignored if it is also present.

ImageMagick is cross-platform, and provides Binary Releases for Linux, Mac OS X, iOS, and Windows alike. It supports a ton of graphic formats (including your requested .jpg and .png). So this should fit your requirements. Due to its working from the command line, it's also faster than many other approaches (as it doesn't have to load a GUI first).

This is a pretty mighty package for image manipulation, so you can use it for many other related tasks as well: montage, animate, compare, identify (i.e. show image meta data), convert between different formats, … Might take a little time to grasp it all, though :)

2
  • +1 When I read the question yesterday I was thinking of finding the right -resize parameters by dichotomy through some wrapper script, -define might be more clever :) Ironically I knew some tools to set a target size for a video (many years ago when I was burning CD/DVD), but not for an image. Jun 11, 2014 at 16:07
  • Thanks, @FranckDernoncourt! I was coming the same way, but did a Ctrl-F for "file size" on the manual before posting. Didn't know about this parameter until an hour ago :)
    – Izzy
    Jun 11, 2014 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.