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

时间:2016-08-04 16:24:47

标签: image-processing imagemagick tiff imagemagick-convert

我试图将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做到这一点?

2 个答案:

答案 0 :(得分:2)

嗯,我尝试了Q16和Q32,HDRI和非HDRI版本的ImageMagick,其中大部分都是大多数选项的组合:

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

我也无法到达任何地方!

我确实取得了一些成功,我认为vips这是一个相当轻量级,易于安装的软件包,但它取决于你以后想要对数据做什么:

你可以转换每个"页面"直接从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

这取决于你接下来要做什么......

答案 1 :(得分:1)

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

关注Mark's fantastic answer,我能够研究以下内容......

私人Tiff标签

TIFF错误

  

转换:抱歉,无法处理32位样本的图像。 `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和&等

然而,图像的最后一层显示为损坏:(

6th layer