Page 1 of 1
Urgent! Recognize Bit-Depth.
Posted: 2013-10-17T10:42:23-07:00
by andrefaria
I have a directory with many different types of images. They have Bit-Depth of 1 bit, and 24 other other 8.
I would like to put in a command where ONLY negative images with 1 bit.
Can anyone help me?
Re: Urgent! Recognize Bit-Depth.
Posted: 2013-10-17T14:45:58-07:00
by fmw42
You have to extract that from the IM verbose information. The string formats "%z" and "%[depth]" only show 8 vs 16, etc
# 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
Re: Urgent! Recognize Bit-Depth.
Posted: 2013-10-18T09:46:19-07:00
by snibgo
An equivalent in Windows, using just Windows tools, is:
Code: Select all
for /F "usebackq tokens=1-2 delims=Depth-bit:/ " %%L ^
in (`%IM%convert -verbose %1 info:^|findstr "Depth"`) do (
set DEPTH=%%M
if "!DEPTH!"=="" set DEPTH=%%L
)
echo Depth of %1 is %DEPTH% bits.
Re: Urgent! Recognize Bit-Depth.
Posted: 2013-10-20T09:35:01-07:00
by snibgo
@andrefaria: See the thread
viewtopic.php?f=2&t=24291 for a new feature that will help.