Imagemagick将tif转换为rgba16 png
这是我的源tif图像:Imagemagick将tif转换为rgba16 png,imagemagick,png,tiff,imagemagick-convert,Imagemagick,Png,Tiff,Imagemagick Convert,这是我的源tif图像: $ identify -verbose source.tif Image: Format: TIFF (Tagged Image File Format) Class: DirectClass Geometry: 512x512+0+0 Resolution: 72x72 Print size: 7.11111x7.11111 Units: PixelsPerInch Type: Palette Base type: TrueColor
$ identify -verbose source.tif
Image:
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 512x512+0+0
Resolution: 72x72
Print size: 7.11111x7.11111
Units: PixelsPerInch
Type: Palette
Base type: TrueColor
Endianess: MSB
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 1-bit
我试过:
转换source.tif output.png
结果如下:
$ identify -verbose output.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 512x512+0+0
Resolution: 28.34x28.34
Print size: 18.0663x18.0663
Units: PixelsPerCentimeter
Type: Palette
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 1-bit
但我不知道如何使PNG成为RGBA16。据我所知,这意味着它需要16位深度和alpha通道。一般来说,ImageMagick将使用与您的规格兼容的最经济的输出格式。因此,如果输入图像没有alpha通道(即透明度),则输出图像将没有透明度。如果256色调色板适合图像中的颜色,它将创建调色板输出图像。如果8位输出深度适合您的图像,则不需要创建16位输出。等等 如果您想强制ImageMagick做一些不同的事情,您有很多选择 如果要强制使用真彩色或调色板(索引)输出文件,可以执行以下操作:
convert input.png -type palette output.png # Force palettised (indexed) output
convert input.png -type truecolor output.png # Force true colour output
convert input.png -depth 8 output.png # Force 8-bit output
convert input.png -depth 16 output.png # Force 16-bit (per channel) output
如果要强制8位或16位,可以执行以下操作:
convert input.png -type palette output.png # Force palettised (indexed) output
convert input.png -type truecolor output.png # Force true colour output
convert input.png -depth 8 output.png # Force 8-bit output
convert input.png -depth 16 output.png # Force 16-bit (per channel) output
如果要强制使用alpha/透明度通道,可以执行以下操作:
convert input.tif -type TrueColorAlpha output.png # Force a true color output with transparency
你也可以把这些结合起来。如果要查看类型选项,请使用以下命令:
identify -list type
Bilevel
ColorSeparation
ColorSeparationAlpha
ColorSeparationMatte
Grayscale
GrayscaleAlpha
GrayscaleMatte
Optimize
Palette
PaletteBilevelAlpha
PaletteBilevelMatte
PaletteAlpha
PaletteMatte
TrueColorAlpha
TrueColorMatte
TrueColor
此外,特别是在PNG
文件的情况下,您还可以通过以大写字母指定PNG类型,然后在输出文件名前面加一个冒号来强制输出,因此:
convert input.tif PNG64:output.png # Force 64-bit RGBA (3 channels @ 16-bits each, plus alpha)
convert input.tif PNG32:output.png # Force 32-bit RGBA (3 channels @ 8-bits each, plus alpha)
convert input.tif PNG48:output.png # Force 48-bit output (3 channels @ 16-bits each, no alpha)
convert input.tif PNG24:output.png # Force 24-bit output (3 channels @ 8-bits each, no alpha)
所以简单的答案是
convert input.tif PNG64:output.png
或
但是要注意,如果输入图像中没有alpha通道,ImageMagick将覆盖第二个版本,而如果使用
PNG64:
则不会覆盖第二个版本。通常,ImageMagick将使用与您的规范兼容的最经济的输出格式。因此,如果输入图像没有alpha通道(即透明度),则输出图像将没有透明度。如果256色调色板适合图像中的颜色,它将创建调色板输出图像。如果8位输出深度适合您的图像,则不需要创建16位输出。等等
如果您想强制ImageMagick做一些不同的事情,您有很多选择
如果要强制使用真彩色或调色板(索引)输出文件,可以执行以下操作:
convert input.png -type palette output.png # Force palettised (indexed) output
convert input.png -type truecolor output.png # Force true colour output
convert input.png -depth 8 output.png # Force 8-bit output
convert input.png -depth 16 output.png # Force 16-bit (per channel) output
如果要强制8位或16位,可以执行以下操作:
convert input.png -type palette output.png # Force palettised (indexed) output
convert input.png -type truecolor output.png # Force true colour output
convert input.png -depth 8 output.png # Force 8-bit output
convert input.png -depth 16 output.png # Force 16-bit (per channel) output
如果要强制使用alpha/透明度通道,可以执行以下操作:
convert input.tif -type TrueColorAlpha output.png # Force a true color output with transparency
你也可以把这些结合起来。如果要查看类型选项,请使用以下命令:
identify -list type
Bilevel
ColorSeparation
ColorSeparationAlpha
ColorSeparationMatte
Grayscale
GrayscaleAlpha
GrayscaleMatte
Optimize
Palette
PaletteBilevelAlpha
PaletteBilevelMatte
PaletteAlpha
PaletteMatte
TrueColorAlpha
TrueColorMatte
TrueColor
此外,特别是在PNG
文件的情况下,您还可以通过以大写字母指定PNG类型,然后在输出文件名前面加一个冒号来强制输出,因此:
convert input.tif PNG64:output.png # Force 64-bit RGBA (3 channels @ 16-bits each, plus alpha)
convert input.tif PNG32:output.png # Force 32-bit RGBA (3 channels @ 8-bits each, plus alpha)
convert input.tif PNG48:output.png # Force 48-bit output (3 channels @ 16-bits each, no alpha)
convert input.tif PNG24:output.png # Force 24-bit output (3 channels @ 8-bits each, no alpha)
所以简单的答案是
convert input.tif PNG64:output.png
或
但是要注意,如果输入图像中没有alpha通道,ImageMagick将覆盖第二个版本,而如果使用
PNG64:
则不会覆盖整个命令行吗?因此,似乎没有理由升级目标频道,因为源频道完全适合。我不确定我是否理解。您的输入格式8-8-1(顺便说一句,这是不寻常的)似乎被转换为完全相同的PNG格式。convert
命令按您的指示执行,没有任何提示。也许你需要告诉它你想要一个16位的输出(如果我理解正确的话,它需要下采样到4-4-4-4通道)。这是你的整个命令行吗?因此,似乎没有理由升级目标频道,因为源频道完全适合。我不确定我是否理解。您的输入格式8-8-1(顺便说一句,这是不寻常的)似乎被转换为完全相同的PNG格式。convert
命令按您的指示执行,没有任何提示。也许你需要告诉它你想要一个16位的输出(如果我理解正确的话,需要下采样到4-4-4-4通道)。谢谢你的解释!那么,如果我想要rgba16,为什么是PNG64呢?因为4个通道@16位每个=64出于某种原因,我在命令中遇到了这个错误:convert:无法打开图像`PNG64:output.png':@error/blob.c/OpenBlob/2517。如果运行convert-size 100x100 xc:black a.png
我在运行identifite-list时似乎也缺少TrueCorAlpha,会发生什么谢谢你的解释!那么,如果我想要rgba16,为什么是PNG64呢?因为4个通道@16位每个=64出于某种原因,我在命令中遇到了这个错误:convert:无法打开图像`PNG64:output.png':@error/blob.c/OpenBlob/2517。如果运行convert-size 100x100 xc:black a.png
我在运行identifite-list时似乎也缺少TrueCorAlpha,会发生什么类型