#! /bin/csh -f # Last edited on 2005-05-05 21:42:24 by stolfi set usage = "$0 WIDTH.HEIGHT..." # Given a list of WIDTH.HEIGHT pairs, outputs the one that is closest # to the standard portrait size (280 x 392). echo "script = ${0}" if ( $#argv == 0 ) then echo "usage: ${usage}"; exit 1 endif set sizes = ( $* ) @ idealarea = 280 * 392 set bestsize = 0.0; set bestadif = ${idealarea} foreach sz ( $sizes ) @ szx = ${sz:r} @ szy = ${sz:e} @ area = ${szx} * ${szy} if ( ${area} > ${idealarea} ) then @ adif = ${area} - ${idealarea} else @ adif = ${idealarea} - ${area} endif if ( ${adif} < ${bestadif} ) then set bestsize = ${sz} set bestadif = ${adif} endif end echo ${bestsize}