Dec 15, 2010 09:45
I got this working pretty quickly and it involved clevering out some arcana, including how to do math with the output of your pipes(?!). Also, if will help me reorganize the wallpaper collection. Exif is a neat tool if you don't have it.
#!/bin/bash
## print images files and their pixel sizes, for wallpaper
## might take target from first argument
## requires exif package, available in apt
for image in *.jpg; ##$1;
do
while exif --tag PixelXDimension $image 2>&1 > /dev/null ;
do
echo -n $image " "
echo -n $((`exif --tag PixelXDimension $image | grep Value | tail -1 | awk '{print $2}'`/2)) x" "
echo -n $((`exif --tag PixelYDimension $image | grep Value | tail -1 | awk '{print $2}'`/2)) y
echo;
break;
done
done
Sample output:
400177main_MilkyWayCenterComp3000.jpg 1500 x 1200 y
I'm sure none of you care much but I'm quite pleased I was able to figure this out in only a couple tries**
ETA: fixes, works well though there is still some error junk in the output, even with the 2>&1 > dev/null incantation.
**The hours wasted fighting with gem, ImageMagick, macports (sudo mv /opt/not.opt), and make last week will not be spoken of. Take one point from ruby and put it into bash's bucket.
hack