Imagemagick仅读取红色通道

Imagemagick仅读取红色通道,imagemagick,tiff,imagemagick-convert,image-conversion,imagemagick-identify,Imagemagick,Tiff,Imagemagick Convert,Image Conversion,Imagemagick Identify,我有一个TIFF图像,我想把它转换成JPG。在我的本地机器(Ubuntu19.10LTS)上安装了ImageMagick 6.9,目标系统(Alpine 3.12.4)将安装7.0 我使用此命令转换图像: $ identify -verbose 100U.TIF ⬡ 12.18.3 Image: 100U.TIF Format: TIFF (Tagged I

我有一个TIFF图像,我想把它转换成JPG。在我的本地机器(Ubuntu19.10LTS)上安装了ImageMagick 6.9,目标系统(Alpine 3.12.4)将安装7.0

我使用此命令转换图像:

$ identify -verbose 100U.TIF                                                                    ⬡ 12.18.3 
Image: 100U.TIF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 288x213+0+0
  Resolution: 75x75
  Print size: 3.84x2.84
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: TrueColor
  Endianess: LSB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 61344
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 2.78762 (0.0109319)
      standard deviation: 23.7277 (0.0930497)
      kurtosis: 87.1252
      skewness: 9.22018
      entropy: 0.0306475
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 2.04869 (0.00803409)
      standard deviation: 21.3045 (0.0835469)
      kurtosis: 115.249
      skewness: 10.7066
      entropy: 0.0185803
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 81.2182 (0.318503)
      standard deviation: 62.7872 (0.246224)
      kurtosis: -1.32139
      skewness: -0.234594
      entropy: 0.679964
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 28.6848 (0.11249)
      standard deviation: 35.9398 (0.14094)
      kurtosis: 1.38693
      skewness: 1.63363
      entropy: 0.243064
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 288x213+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Properties:
    date:create: 2021-04-08T09:06:20+02:00
    date:modify: 2021-04-08T08:27:56+02:00
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 4
  Artifacts:
    filename: 100U.TIF
    verbose: true
  Tainted: False
  Filesize: 65350B
  Number pixels: 61344
  Pixels per second: 6.1344MB
  User time: 0.010u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
convert 100U.TIF 100U.JPG

在我的本地机器上,图像显示正确,而在目标系统上,只有红色通道被转换

在本地计算机上识别在图像上为我提供以下输出:

$ identify -verbose 100U.TIF                                                                    ⬡ 12.18.3 
Image: 100U.TIF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 288x213+0+0
  Resolution: 75x75
  Print size: 3.84x2.84
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: TrueColor
  Endianess: LSB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 61344
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 2.78762 (0.0109319)
      standard deviation: 23.7277 (0.0930497)
      kurtosis: 87.1252
      skewness: 9.22018
      entropy: 0.0306475
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 2.04869 (0.00803409)
      standard deviation: 21.3045 (0.0835469)
      kurtosis: 115.249
      skewness: 10.7066
      entropy: 0.0185803
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 81.2182 (0.318503)
      standard deviation: 62.7872 (0.246224)
      kurtosis: -1.32139
      skewness: -0.234594
      entropy: 0.679964
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 28.6848 (0.11249)
      standard deviation: 35.9398 (0.14094)
      kurtosis: 1.38693
      skewness: 1.63363
      entropy: 0.243064
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 288x213+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Properties:
    date:create: 2021-04-08T09:06:20+02:00
    date:modify: 2021-04-08T08:27:56+02:00
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 4
  Artifacts:
    filename: 100U.TIF
    verbose: true
  Tainted: False
  Filesize: 65350B
  Number pixels: 61344
  Pixels per second: 6.1344MB
  User time: 0.010u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
而目标系统上的识别为我提供了以下信息:

# magick identify -verbose 100U.TIF -set type TrueColor
Image:
  Filename: 100U.TIF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 288x213+0+0
  Resolution: 75x75
  Print size: 3.84x2.84
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: Palette
  Base type: TrueColor
  Endianness: LSB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 1-bit
    Blue: 1-bit
  Channel statistics:
    Pixels: 61344
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 17.95 (0.0703921)
      median: 0 (0)
      standard deviation: 43.4868 (0.170536)
      kurtosis: 3.56005
      skewness: 2.22319
      entropy: 0.223782
    Green:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: 0
    Blue:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: 0
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 5.98333 (0.023464)
      median: 0 (0)
      standard deviation: 14.4956 (0.0568454)
      kurtosis: 19.9054
      skewness: 4.51667
      entropy: 0.074594
  Colors: 238
  Histogram:[...]
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 288x213+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Convex hull: 263,2 278,2 287,4 287,167 276,192 255,193 171,193 29,156 8,47 80,13 113,6 161,4 263,2 
  Minimum bounding box: 287,2 287,193 8,193 8,2 
  Properties:
    date:create: 2021-04-08T07:06:20+00:00
    date:modify: 2021-04-08T06:27:56+00:00
    minimum-bounding-box:_p: 263,2
    minimum-bounding-box:_q: 278,2
    minimum-bounding-box:_v: 255,193
    minimum-bounding-box:angle: 0
    minimum-bounding-box:area: 53289
    minimum-bounding-box:height: 279
    minimum-bounding-box:unrotate: -0
    minimum-bounding-box:width: 191
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 4
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 65350B
  Number pixels: 61344
  Pixels per second: 5.60942MP
  User time: 0.010u
  Elapsed time: 0:01.010
  Version: ImageMagick 7.0.10-48 Q16 x86_64 2020-12-12 https://imagemagick.org
我尝试了参数“-type”、“-colorspace”和“-alpha”的不同值,结果总是只显示红色图像

是不是因为我缺少依赖关系

编辑: 在我发现之后,我可以为所有tiff文件复制它,我自己生成了一个,并在调试开关打开的情况下进行了分析(在alpine系统上)。 从生成的tiff文件位于以下位置:。此处生成的jpg文件:


如果不访问您的文件,很难提供帮助!以下是一些建议:

  • 尝试在调试打开的情况下运行ImageMagick,查看是否可以发现差异:

    magick-identific-debug-all-verbose 100U.tif

  • 尝试使用exiftool查看文件的组成:

    exiftool-v-v 100U.tif


如果您有docker,您可以非常快速地运行一个一次性Alpine实例,并在其上安装ImageMagick,然后尝试如下操作:

docker run --rm -it -v "$(pwd)":/work alpine:latest

/ # apk add --no-cache imagemagick
/ # cd work
/work # magick 100U.TIF 100U.JPG

如果不访问您的文件,很难提供帮助!以下是一些建议:

  • 尝试在调试打开的情况下运行ImageMagick,查看是否可以发现差异:

    magick-identific-debug-all-verbose 100U.tif

  • 尝试使用exiftool查看文件的组成:

    exiftool-v-v 100U.tif


如果您有docker,您可以非常快速地运行一个一次性Alpine实例,并在其上安装ImageMagick,然后尝试如下操作:

docker run --rm -it -v "$(pwd)":/work alpine:latest

/ # apk add --no-cache imagemagick
/ # cd work
/work # magick 100U.TIF 100U.JPG

正如fmw42指出的,7.0.10-48似乎有一个bug(将尝试在问题跟踪程序中找到它)。更新到7.0.10-57修复了该问题。

正如fmw42所指出的,7.0.10-48似乎有一个bug(将尝试在问题跟踪器中找到它)。更新到7.0.10-57修复了此问题。

此问题与我的问题类似。我在更新imagemagick版本后解析


这个问题和我的问题一样。我在更新imagemagick版本后解析


不幸的是,我无法共享该文件。另一件事:我还将正确的jpg转换为tiff文件并返回,这导致了相同的问题,最后的结果中只有红色通道。7.0.10-48 Imagemagick可能有错误。你能试试别的版本吗。目前是7.0.11-6。这两个系统上都有什么版本的libtiff和libjpeg。如果不是最新的,你可以升级它们。哇。。非常感谢。使用7.0.10-57已经解决了这个问题。不幸的是,我无法共享该文件。另一件事:我还将正确的jpg转换为tiff文件并返回,这导致了相同的问题,最后的结果中只有红色通道。7.0.10-48 Imagemagick可能有错误。你能试试别的版本吗。目前是7.0.11-6。这两个系统上都有什么版本的libtiff和libjpeg。如果不是最新的,你可以升级它们。哇。。非常感谢。使用7.0.10-57已经解决了这个问题。我刚刚意识到,每个tiff到jpg的转换都失败了。因此,我拍摄了一张免费图像(),将其转换为tiff:
convert butterfly-1390152.jpg butterfly-1390152.tiff
并返回:
convert butterfly-1390152.tiff butterfly-1390152..jpg
结果:将此结果和调试输出添加到看起来像bug的主要问题中。照片类型的图像不太可能有如此少的颜色,以至于可以用调色板来表示,更不可能两幅图像都有8位红色通道,只有1位绿色和蓝色通道。我怀疑是bug或是libtiff的不兼容版本。我刚刚意识到,每个tiff到jpg的转换都失败了。因此,我拍摄了一张免费图像(),将其转换为tiff:
convert butterfly-1390152.jpg butterfly-1390152.tiff
并返回:
convert butterfly-1390152.tiff butterfly-1390152..jpg
结果:将此结果和调试输出添加到看起来像bug的主要问题中。照片类型的图像不太可能有如此少的颜色,以至于可以用调色板来表示,更不可能两幅图像都有8位红色通道,只有1位绿色和蓝色通道。我怀疑有bug或不兼容版本的
libtiff
。找不到匹配的bug,但其中一个提交可能是“解决方案”(更正/还原以前的更改看起来可疑;):找不到匹配的bug,但其中一个提交可能是“解决方案”(更正/恢复以前的更改看起来可疑;):