mrgloom
mrgloom

Reputation: 21632

ImageMagick: split multipage 32 float TIFF image

I'm trying to convert 32-bit multipage TIFF image to several single TIFF images.

Command from here

convert -depth 32 temp.tif single%d.tif

convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.

Seems it can't work with 32-bit images by default convert: Sorry, can not handle images with 32-bit samples.

convert -version

Version: ImageMagick 7.0.2-6 Q16 x64 2016-07-30 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 Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pa
ngocairo png ps rsvg tiff webp xml zlib

Is there any way to do it with ImageMagick?

Upvotes: 1

Views: 2074

Answers (2)

emcconville
emcconville

Reputation: 24419

The format is highly extendable, and I would suggest finding/researching the proprietary software used to generate the images.

Following Mark's fantastic answer, I was able to research the following...

Private Tiff Tags

TIFF Errors

convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/tiff.c/TIFFErrors/564

This message comes from libtiff library that was linked to by ImageMagick. It simply doesn't support TIFFTAG_BITSPERSAMPLE of 32-bit per sample. Here's a code-snippet of TIFFRGBAImageBegin method used by the tiff library.

TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
switch (img->bitspersample) {
case 1: case 2: case 4:
case 8: case 16:
break;
default:
sprintf(emsg, "Sorry, can not handle images with %d-bit samples",
    img->bitspersample);
return (0);
}

Alternative tiffsplit

If the task is just to spite the layers into isolated images, perhaps the tiffsplit will work...

tiffsplit temp.tif single_

... which will generate single_aaa.tif, single_aab.tif, & etc.

However the last layer of the image appears corrupt :(

6th layer

Upvotes: 1

Mark Setchell
Mark Setchell

Reputation: 207465

Mmmm, I have tried Q16 and Q32, HDRI and Non-HDRI versions of ImageMagick with most combinations of most of these options:

  • -define quantum:format=floating-point
  • -depth 32
  • -define tiff:ignore-tags=42113,34737,34736
  • -define quantum:format=signed

and I can't get anywhere either!

I did have some success, I think with vips which is a fairly light-weight, easily installed package but it kind of depends what you want to do with the data afterwards:

Either you could convert each "page" straight from TIF to 32-bit PNG with this:

vips im_vips2png temp.tif:1 1.png
vips im_vips2png temp.tif:2 2.png

Or, you could go the long way round via PPM format:

# Convert first "page" in TIF to vips format
vips im_tiff2vips temp.tif:1 1.v

# Convert second "page" in TIF to vips format
vips im_tiff2vips temp.tif:2 2.v

... and so on for all 5 pages.

Then I can convert those to float PPMs with vips

vips ppmsave 1.v 1.ppm
vips ppmsave 2.v 2.ppm

And now ImageMagick can process the PPM files:

convert 1.ppm a.png

It kind of depends what you want to do next...

Upvotes: 2

Related Questions