I need to convert files to tiff where photometric is set "min-is-white" (white is zero) to comply with the required standards. I'm using Wand to interact with Photomagick but every I save a bilevel tiff file, it creates a min-is-black.
我需要将文件转换为tiff,其中光度计设置为“min-is-white”(白色为零)以符合所需标准。我正在使用Wand与Photomagick进行交互,但每次我保存一个双层tiff文件,它会创建一个min-is-black。
How can I get Wand to saves it where White is Zero? Is it even possible?
如何将魔杖保存在白色为零的地方?它甚至可能吗?
1 个解决方案
#1
2
Mark's comments are correct. You need to set the -define
property for ImageMagick.
马克的评论是正确的。您需要为ImageMagick设置-define属性。
For wand, you'll have to extent the core wand.api.library
to connect MagickWand's C-API MagickSetOption
method.
对于魔杖,你必须扩展核心wand.api.library以连接MagickWand的C-API MagickSetOption方法。
from ctypes import c_void_p, c_char_p
from wand.api import library
from wand.image import Image
# Tell python about the MagickSetOption method
library.MagickSetOption.argtypes = [c_void_p, # MagickWand * wand
c_char_p, # const char * option
c_char_p] # const char * value
# Read source image
with Image(filename="/path/to/source.tiff") as image:
# -define quantum:polarity=min-is-white
library.MagickSetOption(image.wand, # MagickWand
"quantum:polarity", # option
"min-is-white") # value
# Write min-is-white image
image.save(filename="/path/to/min-is-white.tiff")
You can verify the resulting image with the identify
utility.
您可以使用标识实用程序验证生成的图像。
identify -verbose /path/to/min-is-white.tiff | grep photometric
#=> tiff:photometric: min-is-white
#1
2
Mark's comments are correct. You need to set the -define
property for ImageMagick.
马克的评论是正确的。您需要为ImageMagick设置-define属性。
For wand, you'll have to extent the core wand.api.library
to connect MagickWand's C-API MagickSetOption
method.
对于魔杖,你必须扩展核心wand.api.library以连接MagickWand的C-API MagickSetOption方法。
from ctypes import c_void_p, c_char_p
from wand.api import library
from wand.image import Image
# Tell python about the MagickSetOption method
library.MagickSetOption.argtypes = [c_void_p, # MagickWand * wand
c_char_p, # const char * option
c_char_p] # const char * value
# Read source image
with Image(filename="/path/to/source.tiff") as image:
# -define quantum:polarity=min-is-white
library.MagickSetOption(image.wand, # MagickWand
"quantum:polarity", # option
"min-is-white") # value
# Write min-is-white image
image.save(filename="/path/to/min-is-white.tiff")
You can verify the resulting image with the identify
utility.
您可以使用标识实用程序验证生成的图像。
identify -verbose /path/to/min-is-white.tiff | grep photometric
#=> tiff:photometric: min-is-white