Page 1 of 1

identify report wrong format for tiff page.

Posted: 2017-09-25T19:23:43-07:00
by 246246
Using the same image in https://www.imagemagick.org/discourse-s ... =1&t=32672 ,

Code: Select all

$ magick identify logo_mix.tif
logo_mix.tif[0] TIFF 640x480 640x480+0+0 1-bit Bilevel Gray 173172B 0.000u 0:00.000
logo_mix.tif[1] TIFF 640x480 640x480+0+0 2-bit Grayscale Gray 173172B 0.000u 0:00.000
logo_mix.tif[2] TIFF 640x480 640x480+0+0 8-bit Grayscale Gray 173172B 0.000u 0:00.000
logo_mix.tif[3] TIFF 640x480 640x480+0+0 8-bit sRGB 256c 173172B 0.000u 0:00.000
logo_mix.tif[4] TIFF 640x480 640x480+0+0 16-bit sRGB 173172B 0.000u 0:00.000

$ magick identify logo_mix.tif[0]
logo_mix.tif[0]=>logo_mix.tif TIFF 640x480 640x480+0+0 1-bit Grayscale Gray 173172B 0.000u 0:00.000
The latter command should output Bilevel Gray.

Version:

Code: Select all

$ magick -version
Version: ImageMagick 7.0.7-4 Q16 x64 2017-09-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib


Re: identify report wrong format for tiff page.

Posted: 2017-09-25T21:13:49-07:00
by fmw42
This works for me on IM 7.0.7.4 Q16 Mac OSX:

Code: Select all

magick logo_mix.tif[0] -depth 1 -type bilevel new.tif
or
magick logo_mix.tif[0] -type bilevel new.tif
or
magick logo_mix.tif[0] -depth 1 new.tif
or
magick logo_mix.tif[0] new.tif


identify new.tif
new.tif TIFF 640x480 640x480+0+0 1-bit Bilevel Gray 7070B 0.000u 0:00.000

Re: identify report wrong format for tiff page.

Posted: 2017-09-26T02:08:11-07:00
by snibgo
I think the OP is asking why one identify command shows the type as "Bilevel", where another shows it as "Grayscale".

The answer is that "Grayscale" comes from the colorspace (which is metadata), whereas "Bilevel" comes from testing all the pixels values for being black or white.

Compare these two commands:

Code: Select all

f:\web\im>%IM%convert logo_mix.tif[0] -identify NULL:
logo_mix.tif[0]=>logo_mix.tif TIFF 640x480 640x480+0+0 1-bit Bilevel Gray 173KB 0.000u 0:00.000

f:\web\im>%IM%convert -ping logo_mix.tif[0] -identify NULL:
logo_mix.tif[0]=>logo_mix.tif TIFF 640x480 640x480+0+0 1-bit Grayscale Gray 173KB 0.000u 0:00.000
The "identify" command generally doesn't read the pixels, because most uses of identify without "-verbose" don't need pixel values. The "convert" command generally does read all the pixels.

Re: identify report wrong format for tiff page.

Posted: 2017-09-26T08:20:06-07:00
by 246246
Thank you for explanation. I had never used -identify option for convert, though I found another way to show 'Bilevel' output for both:

Code: Select all

$ identify -format "%[colorspace] %[type]\n" logo_mix.tif
Gray Bilevel
Gray Grayscale
Gray Grayscale
sRGB Palette
sRGB Palette
$ identify -format "%[colorspace] %[type]\n" logo_mix.tif[0]
Gray Bilevel
Document clearly says %[type] is CALCULATED. https://www.imagemagick.org/script/escape.php

I cannot find a clear document for identify output (when invoked without options), what information is shown at there, but can guess it tried to show best from known information.

So I'm still curious why my first command ($ magick identify logo_mix.tif) need to read all pixels of the first page...