Skip to content

Instantly share code, notes, and snippets.

@lunaroja
Created June 9, 2016 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lunaroja/5e109633cf71feceb97fcfea7c1f92e3 to your computer and use it in GitHub Desktop.
Save lunaroja/5e109633cf71feceb97fcfea7c1f92e3 to your computer and use it in GitHub Desktop.
json with image dimensions from directory
function imagesizes() {
for filename in *; do
imgsize "$filename"
done
}
function imgsize() {
local width height
if [[ -f $1 ]]; then
height=$(sips -g pixelHeight "$1"|tail -n 1|awk '{print $2}')
width=$(sips -g pixelWidth "$1"|tail -n 1|awk '{print $2}')
echo "{ 'src': '${1}', 'width': '${width}', 'height': '${height}' },"
else
echo "File not found"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment