ImageMagick:拆分多页 32 浮动 TIFF 图像

ImageMagick: split multipage 32 float TIFF image

我正在尝试将 32 位多页 TIFF 图像转换为多个单 TIFF 图像。

来自 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.

默认情况下似乎无法使用 32 位图像 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

有什么方法可以用 ImageMagick 做到吗?

嗯,我已经尝试了 Q16 和 Q32,ImageMagick 的 HDRI 和非 HDRI 版本以及这些选项的大多数组合:

  • -定义quantum:format=浮点数
  • -深度 32
  • -定义tiff:ignore-tags=42113,34737,34736
  • -定义 quantum:format=signed

我也哪儿也去不了!

我确实取得了一些成功,我认为 vips 是一个相当轻量级、易于安装的软件包,但它在某种程度上取决于你之后想对数据做什么:

或者您可以将每个 "page" 直接从 TIF 转换为 32 位 PNG,方法是:

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

或者,您可以通过 PPM 格式走很长的路:

# 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

...所有 5 页依此类推。

然后我可以使用 vips

将它们转换为浮点 PPM
vips ppmsave 1.v 1.ppm
vips ppmsave 2.v 2.ppm

现在 ImageMagick 可以处理 PPM 文件了:

convert 1.ppm a.png

这取决于你下一步想做什么...

格式具有高度可扩展性,我建议 finding/researching 用于生成图像的专有软件。

之后,我能够研究以下...

私人 Tiff 标签

TIFF 错误

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

此消息来自 ImageMagick 链接到的 libtiff 库。它根本不支持每个样本 32 位的 TIFFTAG_BITSPERSAMPLE。这是 tiff 库使用的 TIFFRGBAImageBegin 方法的代码片段。

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);
}

替代 tiffsplit

如果任务只是将图层分割成孤立的图像,也许 tiffsplit 会起作用...

tiffsplit temp.tif single_

... 将生成 single_aaa.tifsingle_aab.tif

然而图像的最后一层似乎损坏了:(