Last active
March 21, 2023 23:43
-
-
Save raspi/d8f628317fbc02bcf2f68bae05d7b6ca to your computer and use it in GitHub Desktop.
Output JSON from ImageMagick magick identify command
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
#!/bin/bash -e | |
# Output JSON from ImageMagick magick identify command | |
if [[ $# -eq 0 ]] ; then | |
echo "Usage:" | |
echo " $0 <filename>" | |
echo "" | |
exit 0 | |
fi | |
FORMAT='{"filesize": "%[size]", "format": "%m", "height": %h, "width": %w, "compression_type": "%C", "compression": %Q}' | |
magick identify -precision 0 -format "$FORMAT" $1 | perl -pe 's@"filesize": "([^\"]+)B"@"filesize": \1@g' | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment