Imagemagick jpeg压缩无法将某些TIFF转换为Pyramid TIFF,但并非全部

问题描述 投票:0回答:2

我使用以下循环将大约250个.tif文件转换为平铺金字塔.tif文件,每个文件大约15到35 mb:

for i in *.tif; do convert $i -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:tiled-'$i; done

这可能适用于超过一半的图像:我得到一个压缩的,平铺的.tif文件,大小约为原始文件的1/4。对于那些不工作的,我得到的图像文件输出大概可能大约4,000字节,而且似乎用-debug all弹出的一个错误是Bogus input colorspace. "JPEGLib"。如果通过IIP图像服务器传送这些图像,则不会出现这些图像,也不会在图像查看器中打开。

我把它本地化为-compress jpeg论证。如果我没有压缩运行,或像-compress LossLess JPEG那样无损压缩,它似乎工作,但平铺图像(显然)比原来大,这是我试图避免。

运行tiffinfo对不能转换为我得到的图像的图像:

Broken

$ tiffinfo WH-001.tif
    TIFF Directory at offset 0x106842c (17204268)
      Image Width: 1735 Image Length: 2479
      Resolution: 72, 72 pixels/inch
      Bits/Sample: 8
      Compression Scheme: None
      Photometric Interpretation: RGB color
      Extra Samples: 1<unassoc-alpha>
      FillOrder: msb-to-lsb
      Orientation: row 0 top, col 0 lhs
      Samples/Pixel: 4
      Rows/Strip: 1
      Planar Configuration: single image plane
      Page Number: 0-1
      DocumentName: WH-001.tif

Working

$ tiffinfo WH-090.tif
    TIFFReadDirectory: Warning, Unknown field with tag 32934 (0x80a6) encountered.
    TIFF Directory at offset 0xd4 (212)
      Subfile Type: (0 = 0x0)
      Image Width: 2800 Image Length: 4160
      Resolution: 600, 600 pixels/inch
      Bits/Sample: 8
      Compression Scheme: None
      Photometric Interpretation: RGB color
      FillOrder: msb-to-lsb
      Orientation: row 0 top, col 0 lhs
      Samples/Pixel: 3
      Rows/Strip: 3
      Planar Configuration: single image plane
      Software: Oi/GFS, writer v00.06.02
      Tag 32934: 0
      ICC Profile: <present>, 3144 bytes

虽然我不知道该怎么说出为什么一个被打破以及为什么另一个有效。

image image-processing imagemagick tiff tile
2个回答
1
投票

我会考虑在这里使用libvips而不是convert

在这款带有10k x 10k像素JPG源的笔记本电脑上,我看到:

$ /usr/bin/time -f %M:%e convert wtc.jpg -define tiff:tile-geometry=256x256 -compress jpeg ptif:im.tif
1628568:34.29

所以这是1.6gb内存的峰值和34s的经过时间。

随着libvips我看到:

$ /usr/bin/time -f %M:%e vips tiffsave wtc.jpg vips.tif --tile --pyramid --compression jpeg
53148:1.95

53mb的内存和2s的经过时间。它的速度提高了15倍,内存减少了30倍。它也使小金字塔:

$ ls -l vips.tif im.tif 
-rw-r--r-- 1 john john 60672180 Mar  7 23:12 im.tif
-rw-r--r-- 1 john john 21419592 Mar  7 23:13 vips.tif

convert不启用YCbCr模式,因此金字塔大3倍。他们应该在iipimage中正常工作。

libvips还会自动为您提供透明度。

文档遍历tiffsave的所有选项:

https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-tiffsave


0
投票

首先,通过检查它们是否能够在其他图像查看器中打开来确保“破碎的”实际上没有被破坏。

其次,我同意你的怀疑,它与-compress jpeg选项有关。原因是您的“损坏”图像包含透明度(请参阅Extra Samples: 1<unassoc-alpha>行),JPEG格式不支持以透明度(alpha)存储图像。

请参阅this other post以从图像文件中删除透明度。

© www.soinside.com 2019 - 2024. All rights reserved.