【问题标题】:What is the MagickWand equivalent of the "-colors" option?“-colors”选项的 MagickWand 等效项是什么?
【发布时间】:2011-04-12 23:02:35
【问题描述】:

我有几张正在使用 ImageMagick 处理的图像。在这种情况下,我将 RGBA PNG 转换为索引 PNG。如果我使用convert 工具,我可以合理控制索引 PNG 中的颜色数量:

$ convert infile.png -colors 128 outfile.png
$ identify outfile.png
outfile.png PNG 77x77 77x77+0+0 8-bit PseudoClass 91c 3.03KiB 0.000u 0:00.000

它似乎大大减少了颜色计数 (91 MagickQuantizeImage(wand, 128, RGBColorspace, tree_depth=1, 0, 0) 进行相同的转换。函数的签名是

MagickBooleanType MagickQuantizeImage(
              MagickWand       *wand,
        const size_t            number_colors,
              ColorspaceType    colorspace,
        const size_t            treedepth,
        const MagickBooleanType dither,
        const MagickBooleanType measure_error)

最终结果是图像颜色太少(只有 11 种!):

$ identify wandoutfile.png
wandoutfile.png PNG 77x77 77x77+0+0 8-bit PseudoClass 11c 1.31KiB 0.000u 0:00.000

有谁知道如何使用 MagickWand 减少颜色(在此过程中不破坏图像?)

谢谢!

【问题讨论】:

  • 你有想过这个吗?
  • 没有。我在一个不错的课程中结束了转换的呼吁,然后继续生活。

标签: imagemagick magickwand


【解决方案1】:

使用treedepth=8, measure_error=1。见the documentation for details

您也可以考虑按照here 的建议使用 YIQ 颜色空间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-30
    • 1970-01-01
    • 1970-01-01
    • 2012-12-27
    • 2018-11-12
    • 2012-10-16
    相关资源
    最近更新 更多