December 15th, 2010

bolts, writing, nuts

./sizes *.jpg

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.

## 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;
while exif --tag PixelXDimension $image 2>&1 > /dev/null ;
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

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.
  • Current Music
    Bleach soundtracks
  • Tags