adric: (nuts)
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.

Profile

adric: books icon (c) 2004 adric.net (Default)
adric

November 2025

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526 2728 29
30      

Links

Syndicate

RSS Atom

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated 18 December 2025 01:02 pm
Powered by Dreamwidth Studios