identify report wrong format for tiff page.

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

identify report wrong format for tiff page.

Post 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

User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify report wrong format for tiff page.

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: identify report wrong format for tiff page.

Post 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.
snibgo's IM pages: im.snibgo.com
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: identify report wrong format for tiff page.

Post 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...
Post Reply