View Single Post
Old 08-13-2012, 05:42 PM   #1
shorshe
Enthusiast
shorshe began at the beginning.
 
shorshe's Avatar
 
Posts: 28
Karma: 10
Join Date: Aug 2012
Location: Munich, Germany
Device: iPad
Post Script to resize images to 2 Million Pixels

Hi all!

A friend an I cobbled together a very rough script for OSX to resize large images down to 2 Million Pixels to conform with iBookstore Asset Guide 4.7 Rev.3:
  • The maximum recommended size is 2 million pixels per image. Larger images may not appear as expected in the iBooks app.

I also used platypus to convert it to an OSX-App.

Download App here:

http://mmsizr.googlecode.com/files/MMSizr.app.zip


Usage:
  • Unzip epub.
  • Start App and drop your images Folder on main window.
  • App searches for jpg, png, gif images an resizes to 2 Million pixels if necessary.
Image names must not contain whitespaces.

Original shell-Script:
Code:
#!/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/.* //"`
    pxlnmbr=`echo "$h*$w" | bc`;
    echo "Number of Pixels in $v ($w x $h) is $pxlnmbr";
    if [[ $anzahl -gt $MAXsize ]]; then
    factor=`echo "scale=5 ; sqrt($MAXsize / $pxlnmbr) " | bc`;
    echo "factor: $factor";
    newWidth=`echo "scale=5 ; $w * $factor" | bc`;
    newHeight=`echo "scale=5 ; $h * $factor" | bc`;
    echo "$v new: $newWidth x $newHeight";
    sips -z $newHeight $newWidth $v
    echo " ";
    fi
done
yes it's rough. Please feel free to improve:
http://mmsizr.googlecode.com/files/mmsizr.sh.zip

Project page:
https://code.google.com/p/mmsizr/

--edit--

Download App here:

http://mmsizr.googlecode.com/files/MMSizr.app.zip

Consider Flattering this article, if you liked this app:
http://suntoucher.de/mmsizr-a-script...illion-pixels/

Last edited by shorshe; 09-05-2012 at 05:53 AM.
shorshe is offline   Reply With Quote