Sxiv comes with a little script to display image information in its status bar. By default this uses ImageMagick’s identify to display geometry.
On NetBSD (theme de jour) the identify binary doesn’t work for me; this may be nothing to do with NetBSD and more to do with a dying hard drive; it can bloody-well last a bit longer.
Since the script also uses exiv2 I thought I’d see if I could get geometry information from that. And you can!
geometry=$(exiv2 "$1" 2>/dev/null | grep "Image size" | cut -f 2 -d : | tr -d " ")
exiv2
reports the image size by default:
File name : netbsd_wallpaper.jpg
File size : 466756 Bytes
MIME type : image/jpeg
Image size : 1024 x 768
netbsd_wallpaper.jpg: No Exif data found in the file
So all that was necessary was to filter for that line via grep
and then cut
out just the dimensions, finally using tr
to remove the spaces. The 2>/dev/null
just gets rid of the “No Exif…” line; alternatively I could have used 2>&1
to ensure this line also went through grep
, but I didn’t, so there; Oddly the -q
(quiet) option of exiv2
doesn’t suppress this message.
There’s no point in doing a pull request for this because of issue 77 - I can’t get that to work, but I don’t care about gifs.