When creating ePub-files I often got an error message from apple: Image exceeds 2 million pixels.
I did not find any ready to use solutions to this problem.
A friend of mine an I created this shell script for osx to do this automagically. It uses the preinstalled commandline tools »bc« and »sips«.
I used Platypus to make a (very basic) GUI-App for this script. Just drag your image folder on the apps main window and every JPG, GIF an PNG will be resized if necessary.
Download app here:
MMsizr App
Feel free to suggest any improvements.
#!/bin/sh MAXsize=1900000; 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 " "; fi done
Scaling is computed the following way:
$latex scaling=\sqrt{\frac{1900000}{NumberOfPixels}}$