Search code examples
image-processingimagemagicktiffimagemagick-convert

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?


Solution

  • 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...