Page 1 of 2

Sorry, can not handle images with 32-bit samples

Posted: 2019-05-18T01:14:10-07:00
by ITWarrior
Hi folks,

I'm having a hard time working with tiffs in ImageMagick. This is my first time properly using ImageMagick. The error I'm getting is "Sorry, can not handle images with 32-bit samples". I have Googled this, and found that the version I was using (CentOS 7 EPEL) was compiled with Q16:

Code: Select all

# /usr/bin/convert -list configure | grep 'quantum\|DELEGATES'
DELEGATES     bzlib fontconfig freetype gs jpeg jng jp2 lzma openexr pango png rsvg tiff x11 xml wmf zlib
DISTCHECK_CONFIG_FLAGS 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-dps=no --with-fontpath= --with-gvc=no
I downloaded and compiled the latest ImageMagick from the site today, and compiled it with the flags I needed:

Code: Select all

./configure --with-quantum-depth=32 --enable-hdri --with-jpeg=yes --with-png=yes --with-tiff=yes --with-zlib=yes
Which produces (note the new quantum-depth):

Code: Select all

# /usr/local/bin/convert -list configure | grep 'quantum\|DELEGATES'
CONFIGURE             ./configure  '--with-quantum-depth=32' '--enable-hdri' '--with-jpeg=yes' '--with-png=yes' '--with-tiff=yes' '--with-zlib=yes'
DELEGATES             mpeg openjp2 png ps tiff zlib
DISTCHECK_CONFIG_FLAGS  --disable-deprecated  --with-quantum-depth=32  --with-jemalloc=no  --with-umem=no  --with-autotrace=no  --with-gslib=no  --with-fontpath=  --with-rsvg=no  --with-perl=no 
DELEGATES             jp2 png tiff zlib
But when I try the original conversion again, I get the same error. I'm at a total loss of what might be going on. Has anybody seen this before?:

Code: Select all

# /usr/local/bin/convert dsm.tif out.png
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/995.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/995.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/995.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/995.
convert: Unknown field with tag 42112 (0xa480) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/995.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/995.
convert: Sorry, can not handle images with 32-bit samples. `dsm.tif' @ error/tiff.c/TIFFErrors/656.
#
Thanks a lot for any help.

Re: Sorry, can not handle images with 32-bit samples

Posted: 2019-05-18T04:00:29-07:00
by snibgo
I've never seen that message before.

What was your command? Please link to a sample input file so we can test it doesn't have problems.

What version of IM ("magick -version")? What version of the TIFF library("magick -list format |grep TIFF")?

If your TIFF library is older than v4.0.9 I suggest you upgrade it, rebuild IM and try again.

Note: IM built with a low quantum depth (eg Q16) can read files with higher depth (eg Q32), but will discard precision before storing the image in memory.

Re: Sorry, can not handle images with 32-bit samples

Posted: 2019-05-19T02:49:06-07:00
by ITWarrior
Thanks for the reply. The command was in the original message though disguised in the noise:

/usr/local/bin/convert dsm.tif out.png

Input file: https://dev.aerosurvey.co.nz/files/242/dsm.tif

Versions:

Code: Select all

[root@dev 242]# magick -version
Version: ImageMagick 7.0.8-45 Q32 x86_64 2019-05-18 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC OpenMP(3.1) 
Delegates (built-in): jp2 png tiff zlib

[root@dev 242]# magick -list format |grep TIFF
      EPT  rw-   Encapsulated PostScript with TIFF preview
     EPT2  rw-   Encapsulated PostScript Level II with TIFF preview
     EPT3  rw+   Encapsulated PostScript Level III with TIFF preview
     PTIF* rw+   Pyramid encoded TIFF
     TIFF* rw+   Tagged Image File Format (LIBTIFF, Version 4.0.3)
   TIFF64* rw-   Tagged Image File Format (64-bit) (LIBTIFF, Version 4.0.3)
Bug with ImageMagick perhaps?

Re: Sorry, can not handle images with 32-bit samples

Posted: 2019-05-19T03:49:30-07:00
by snibgo
Your LIBTIFF is slightly older than the version currently used by IM. However, that doesn't seem to be the problem. I don't have a version of IM that can read your file dsm.tiff. For example, with IM v7.0.7-28 Q32 with HDRI, ignoring "Unknown field" warnings:

Code: Select all

magick identify -verbose dsm.tiff

identify: Sorry, can not handle images with 32-bit samples. `dsm.tiff' @ error/tiff.c/TIFFErrors/650.
With v6.9.9-40 Q32 HDRI:

Code: Select all

f:\web\im>identify -verbose dsm.tiff

identify: improper image header `dsm.tiff' @ error/tiff.c/ReadTIFFImage/1597.
Gimp v2.10 and Microsoft Photo Viewer can both open the file. Gimp says it is 32-bit/channel floating point. IM can successfully read/write 32-bit FP tiff files.

I'll defer to the developers.

Re: Sorry, can not handle images with 32-bit samples

Posted: 2019-05-19T06:30:43-07:00
by 246246
It looks ImageMagick failed to read 16 bit float and 32 bit float tiff file when it is encoded in tile format.

Re: Sorry, can not handle images with 32-bit samples

Posted: 2019-05-19T09:35:52-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-14T07:19:34-07:00
by michal
Hello all
It seems I have similar problem !

My TIFF file is comming from a 3delight renderer, which converts textures to 32bit tiff, tile based and multi-page (MIP maps).
I'd like to extract each MIP page to separate 32bit, floating, HDR TIFF files.

I cloned latest repo (5cea3640802ee7cdf5cc8d5c43ad0e643670ac75) and build with these configure flags:

Code: Select all

    --enable-hdri=yes --disable-installed --with-quantum-depth=32
This is test file http://cgarea.com/test.tiff
Below are resuts for it. Can anybody comment on this please ?

thanks !
-michal

command:

Code: Select all

    ./convert -depth 32 -define quantum:format=floating-point ~/test.tiff ~/tiles_%d.tiff

output:

Code: Select all

    convert: Sorry, can not handle images with 32-bit samples. `/hal/Projects/temp/magick/test.tiff' @      error/tiff.c/TIFFErrors/665.


command:

Code: Select all

    ./identify ~/test.tiff

output:

Code: Select all

    ~/test.tiff[0] TIFF 512x256 512x256+0+0 32-bit sRGB 1.74689MiB 0.000u 0:00.002
    ~/test.tiff[1] TIFF 512x256 512x256+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[2] TIFF 256x128 256x128+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[3] TIFF 128x64 128x64+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[4] TIFF 64x32 64x32+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[5] TIFF 32x16 32x16+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[6] TIFF 16x8 16x8+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[7] TIFF 8x4 8x4+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[8] TIFF 4x2 4x2+0+0 32-bit sRGB 0.000u 0:00.001
    ~/test.tiff[9] TIFF 2x1 2x1+0+0 32-bit sRGB 0.000u 0:00.001
 

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-14T07:38:22-07:00
by snibgo
What version of IM are you using? What is the complete text output of "convert -version"?

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-14T07:53:39-07:00
by michal
snibgo wrote:
2020-01-14T07:38:22-07:00
What version of IM are you using? What is the complete text output of "convert -version"?

Code: Select all

./convert --version
Version: ImageMagick 7.0.9-17 Q32 x86_64 2020-01-14 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5) 
Delegates (built-in): bzlib fftw fontconfig freetype jng jpeg lzma pangocairo png tiff x xml zlib
Keep in mind that I compiled it with flags in my previous post

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-14T09:12:06-07:00
by snibgo
For v7, I suggest you use "magick", not "convert".

On that file, I get the same error with pre-built v7.0.8-64 on Windows 8.1.

With "-debug all", I also get:
Coder (TIFF) generated an image despite an error (450), notify the developers
2020-01-14T15:49:52+00:00 0:04.171 1.234u 7.0.8 Wand magick[1692]: wandcli.c/CLI
CatchException/242/Wand
Gimp can open the file without complaint.

IM works, provided we use [0]:

Code: Select all

magick test.tiff[0] x.png
It doesn't work with [1] or [2] etc.

IM can successfully read and write multi-image 32-bit FP files, eg:

Code: Select all

magick rose: rose: -define quantum:format=floating-point -depth 32 x1.tiff
I don't know why it has problems with your file. A developer may take a look.

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-14T09:44:50-07:00
by michal
The fact that it works with [0] page and not subsequent pages is related to how "test.tiff" was created (by 3delight texture converter).
It makes the first page 8bit and scaled down - so that the file is easily viewable in various image browsers.
I am interested in extracting exactly [1] page (highest resolution - 32bit float).

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-14T10:06:03-07:00
by snibgo
As a workaround, tiffcp can read the file, and make a new tiff:

Code: Select all

tiffcp test.tiff x.tiff
Then IM can read x.tiff with no problem.

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-14T10:50:15-07:00
by michal
snibgo wrote:
2020-01-14T10:06:03-07:00
As a workaround, tiffcp can read the file, and make a new tiff:

Code: Select all

tiffcp test.tiff x.tiff
Then IM can read x.tiff with no problem.
Thanks!
Also i just learned that tiffsplit can do what I want :)

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-16T00:39:56-07:00
by 246246
With your file, I got the same kind of problem when using LibTIff.NET (in SetDirectorey() method.)
So I I checked, last page of your tiff has the following tag:

SMinSampleValue (340) FLOAT (11) 3<0.00610352 0.00720215 0.00146484>
SMaxSampleValue (341) FLOAT (11) 3<15.125 15.125 15.3125>

According to the libtiff mailing list, https://www.asmail.be/msg0055373960.html
it is libtiff limitation. These values must be the same.

Also from tiff spec, these values does not affect visual appearance of image: https://www.awaresystems.be/imaging/tif ... value.html

So, if you remove these tags first,

Code: Select all

% tiffset -d 9 -u 340 test.tiff
% tiffset -d 9 -u 341 test.tiff
LibTiff.NET no longer complains for it.


But still, magick failed to retrieve the page when the input is modified file as above...

Re: Sorry, can not handle images with 32-bit samples

Posted: 2020-01-20T17:31:49-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.