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 friend of mine an I crea­ted this shell script for osx to do this auto­ma­gi­cal­ly. It uses the pre­instal­led com­man­dli­ne 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­lowing way:
$latex scaling=\sqrt{\frac{1900000}{NumberOfPixels}}$