The string formats "%z" and "%[depth]" only show 8 vs 16, etc (depending upon quantumrange). If one has a binary image the depth in the verbose info shows 8/1-bit.
It would be nice to get the actual bit-depth of 1 in this case.
Right now I can do it by extracting that from the IM verbose information.
# create depth 1 image
convert rose: -threshold 50% rose_t50.png
identify -verbose rose_t50.png
...
Depth: 8/1-bit
In unix, this could get extracted by
depth=`convert rose_t50.png -verbose info: | sed -n 's/^ Depth:[^0-9]*\(.*\)-bit$/\1/p' | tr "/" " " | cut -d\ -f2`
echo "$depth"
1
depth=`convert rose: -verbose info: | sed -n 's/^ Depth:[^0-9]*\(.*\)-bit$/\1/p' | tr "/" " " | cut -d\ -f2`
echo "$depth"
8
It might be nice to have a new string format
convert image -format "%[bit-depth] info:
or if one prefers
convert image -format "%[bitdepth] info:
That gets the actual bit depth such a 1
fast identify for actual bit depth
Re: fast identify for actual bit depth
I prefer bit-depth, it will be available in the next release of ImageMagick.
Code: Select all
C:\Test>identify -format "%[bit-depth]" rose:
8
C:\Test>identify -format "%[bit-depth]" rose_t50.png
1