Skip to content

Instantly share code, notes, and snippets.

@joshpetit
Last active September 8, 2020 15:03
Show Gist options
  • Select an option

  • Save joshpetit/6c076be168a867721e7bffdcc0084fde to your computer and use it in GitHub Desktop.

Select an option

Save joshpetit/6c076be168a867721e7bffdcc0084fde to your computer and use it in GitHub Desktop.
Sxiv image-info script to display ISO, Shutter Speed, Aperture. Requires exiv2
#!/bin/sh
# Called by sxiv(1) whenever an image gets loaded,
# with the name of the image file as its first argument.
# The output is displayed in sxiv's status bar.
# Arguments:
# $1: path to image file
# $2: image width
# $3: image height
s=" | " # field separator
filename=$(basename "$1")
filesize=$(du -Hh "$1" | cut -f 1)
# The '[0]' stands for the first frame of a multi-frame file, e.g. gif.
geometry=$(identify -format '%wx%h' "$1[0]")
iso=$(exiv2 $1 | sed -n -e 's/^ISO speed * //p' | sed -n -e 's/: //p')
exposure=$(exiv2 $1 | sed -n -e 's/^Exposure time * //p' | sed -n -e 's/: //p')
aperature=$(exiv2 $1 | sed -n -e 's/^Aperture * //p' | sed -n -e 's/: //p')
echo "${filesize}${s}${geometry}${s}${iso}${s}${exposure}${s}${aperature}${s}${filename}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment