#!/bin/bash ## display commonly wanted image attributes, including size-in-ER-units; by Eugene Reimer 2003; ## ## PREREQ: identify -- from ImageMagick, works for any supported image-format ## PREREQ: bcf -- from http://ereimer.net/programs/general-purpose-scripts.htm for F in "$@";do X=$(identify -format "size:%wx%h dpi:%x\n" $F); Z=${X% dpi:*}; Z=${Z##*:} W=${Z%x*}; H=${Z#*x}; SZ=$(echo "round(sqrt($W*$H*4/3))" |bc) ##2008-11: using new round function -- see /etc/sbin/bc AR=$(echo "round($W/$H*1000)/1000" |bcf "%5.3f") ##2008-11: as fraction; bcf gives me the desired (printf-style) formatting echo "$F: $X sz:$SZ aspect:$AR" ##2008-11: added SZ; add filename here so it works qualified or not done exit NOTE: the ImageMagick man-page used to have help on -- now need to visit the ImageMagick website to get meaningful info?? OBSOLETE BITS: identify -format "%f: size:%wx%h dpi:%x datetime: %[EXIF:DateTime]\n" "$@" identify -format "%f: size:%wx%h dpi:%x\n" "$@" ##used this until 2007-09-24, when I wanted Aspect-Ratio... sz=$(echo "scale=9; sqrt($W*$H*4/3)" |bc); sz=$(echo "scale=0; ($sz+0.5)/1.0" |bc) ##the way I used to do rounding, and got tired of... ((AR=(W*1000+H/2)/H)) ##the way I used to compute aspect-ratio AR=$(echo "round($W*1000/$H)" |bc) ##2008-11: using bc AR=$(echo "trunc(round($W/$H*1000)/1000)" |bc) ##2008-11: as fraction; trunc removes trailing-zeroes; ==want .5-->0.5