I'm trying to create shell script that returns the largest picture in total dimensions pixel size?
For example:
I have many directory over 7000+, each directory have images:
dir_1/
picture_1.png = 800x600
picture_2.png = 80x100
picture_3.png = 80x640
picture_4.png = 500x630
dir_2/
p_1.png = 800x600
p_2.jpeg = 800x1000
p_3.png = 180x1640
p_4.gif = 500x30
So the result expected is:
the largest one in dir_1 is: picture_1.png
the largest one is dir_2 is: p_2.png
So I was thinking is best way is to find out the total of dimensions after collect the figures .. therefor I try to create bash script with sips command that can collect the figures
Here example :
for f in *;
do
far=$( cd $f/OEBPS/image/ | ls * | egrep 'jpg|png|jpeg')
W=$( sips -g pixelWidth $far | cut -f 2 -d":" )
H=$( sips -g pixelHeight $far | cut -f 2 -d":" )
coll=$(expr $W + $H)
echo $f total is: $coll
cd -
done
But got error on result.
Any idea or better way?
for f in $f/OEBPS/image/*{png,jpeg,jpg}
. A ls will bite you if you have blanks and such in fillenames. – user unknown Apr 25 '15 at 17:18