MMsizr a Script/​App to resize images to 2 million pixels

When crea­ting ePub files I often got an error mes­sa­ge from apple: Image exceeds 2 mil­li­on pixels.

I did not find any rea­dy to use solu­ti­ons to this problem.

A fri­end of mine and I crea­ted this shell script for OSX to do this auto­ma­gi­cal­ly. It uses the pre­instal­led com­mand line tools »bc« and »sips«.

I used Pla­ty­pus to make a (very basic) GUI-​App for this script. Just drag your image fol­der on the apps main win­dow and every JPG, GIF an PNG will be resi­zed if necessary.


Down­load app here:
MMsizr App

Feel free to sug­gest any improvements.

 for v in `find $1/*.jpeg $1/*.jpg $1/*.gif $1/*.png`; do
 h=`sips -g pixelHeight $v | tail -1 | sed "s/.* //"`
 w=`sips -g pixelWidth $v | tail -1 | sed "s/.* //"`
 anzahl=`echo "$h*$w" | bc`;
 echo "Anzahl Pixel in $v ($w x $h) ist $anzahl";
 if [[ $anzahl -gt $MAXsize ]]; then
 factor=`echo "scale=5 ; sqrt($MAXsize / $anzahl) " | bc`;
 echo "Faktor: $factor";
 newWidth=`echo "scale=5 ; $w * $factor" | bc`;
 newHeight=`echo "scale=5 ; $h * $factor" | bc`;
 echo "$v Neu: $newWidth x $newHeight";
 sips -z $newHeight $newWidth $v
 echo " ";

Sca­ling is com­pu­ted the fol­lo­wing way:
$latex scaling=\sqrt{\frac{1900000}{NumberOfPixels}}$

4 Gedanken zu „MMsizr a Script/​App to resize images to 2 million pixels“

  1. Hel­lo, I noti­ced that when I drop a fol­der onto this app, if the­re are any spaces in the fol­der name or fol­der path, it does­n’t work. Is this fixa­ble? Thanks so much!

    • Hi Made­line!
      I can’t offer you a solu­ti­on right now, just a work­around. If you drag the images fol­der onto your desk­top, then on mmsi­zer it should work. This is how I do it.
      After­wards drag it back into the epub folder.

  2. First of all: thank you for this very han­dy utility!!

    My ques­ti­on is: could/​would you be wil­ling to make a new ver­si­on whe­re the maxi­mum num­ber of pixels beco­mes 4.000.000 ins­tead of 2.000.000? Becau­se this has beco­me the new stan­dard for Apple after intro­du­cing the Reti­na dis­plays! Thanks in advance!
    Boele (the Netherlands)

    • Hi Boele!

      No Pro­blem at all. I’ll get to it shortly.
      In my sear­ches I found a limit of 3.200.000 Mil­li­on pixels. Up from 2.000.000. Do you have a link?


Schreibe einen Kommentar