Created
June 9, 2016 03:42
-
-
Save lunaroja/5e109633cf71feceb97fcfea7c1f92e3 to your computer and use it in GitHub Desktop.
json with image dimensions from directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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