Python Wand将tiff更改为min-is-white [英] Python Wand change tiff to min-is-white

查看:167
本文介绍了Python Wand将tiff更改为min-is-white的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将文件转换为tiff,其中光度计设置为min-is-white(白色为零)以符合所需标准。我正在使用Wand与Photomagick进行交互,但每次我保存一个双层tiff文件,它会创建一个min-is-black。

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.

如何让Wand保存它白色是零?它甚至可能吗?

How can I get Wand to saves it where White is Zero? Is it even possible?

推荐答案

马克的评论是正确的。您需要为ImageMagick设置 -define 属性。

Mark's comments are correct. You need to set the -define property for ImageMagick.

对于 wand ,你必须扩展核心 wand.api.library 连接MagickWand的C-API MagickSetOption 方法。

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")

您可以使用<$ c $验证生成的图像c>识别实用程序。

identify -verbose /path/to/min-is-white.tiff | grep photometric
#=> tiff:photometric: min-is-white

这篇关于Python Wand将tiff更改为min-is-white的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆