问题
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.
How can I get Wand to saves it where White is Zero? Is it even possible?
回答1:
Mark's comments are correct. You need to set the -define
property for ImageMagick.
For wand, you'll have to extent the core wand.api.library
to connect MagickWand's C-API MagickSetOption
method.
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
来源:https://stackoverflow.com/questions/35205601/python-wand-change-tiff-to-min-is-white