简体   繁体   English

Image Magick ++等效于convert -fill

[英]Image Magick++ equivalent to convert -fill

I have a convert command that I need to translate into Image Magick function calls. 我有一个转换命令,需要将其转换为Image Magick函数调用。

convert.exe bar.jpg -fuzz 40% -fill "rgb(53456, 35209, 30583)" -opaque "rgb(65535, 65535, 65535)" foo2.jpg convert.exe bar.jpg -fuzz 40%-fill“ rgb(53456,35209,30583)”-不透明的“ rgb(65535,65535,65535)” foo2.jpg

I was wondering if anyone could give me an example of the methods I need to apply to get the same effect? 我想知道是否有人可以举一个我需要应用以获得相同效果的方法的示例?

Thanks for any help! 谢谢你的帮助!

The documentation for Magick++ is pretty clear, but there's a lot more examples using & MagickWand . Magick ++的文档非常清晰,但是还有更多使用MagickWand的示例。 For the most part, -fill is just setting a color attribute that can be applied to a wide variety of actions. 在大多数情况下, -fill只是设置可应用于多种操作的颜色属性。 In Magick++, you would use Image.fillColor ; 在Magick ++中,您将使用Image.fillColor however, the Image.opaque method swaps one color for another. 但是, Image.opaque方法将一种颜色交换为另一种颜色。 In addition to the opaque method, color threshold can be adjusted by setting the -fuzz option with Image.colorFuzz . 除了不透明方法之外,还可以通过使用Image.colorFuzz设置-fuzz选项来调整颜色阈值。

C++ & Magick++ Example C ++和Magick ++示例

#include <Magick++.h> 
#include <iostream>

using namespace std;
using namespace Magick;

int main(int argc, char **argv)
{
    InitializeMagick(*argv);

    // Setup items
    Image image;
    /*
       Remember to read & understand Magick++/Color.h to
       ensure you are initializing the correct color constructor.
     */
    Color target = Color("rgb(65535, 65535, 65535)");
    Color fill   = Color("rgb(53456, 35209, 30583)");

    // Convert 40% to double
    const double fuzz = 40*QuantumRange/100;

    // Read image object
    image.read("bar.jpg");

    // Set fuzz threshold
    image.colorFuzz(fuzz);

    // Apply opaque paint
    image.opaque(target,fill);

    // Save image
    image.write("foo2.jpg");

    return 0;
 }

C & MagickWand Example C&MagickWand示例

#include <stdio.h>
#include <wand/MagickWand.h>

int main(int argc, char **argv) {
    // MagickWand items
    MagickWand *image = NULL;
    PixelWand *target = NULL;
    PixelWand *fill   = NULL;

    // Convert 40% to double
    const double fuzz = 40*QuantumRange/100;

    MagickWandGenesis();

    // Setup Wand
    target = NewPixelWand();
    fill = NewPixelWand();
    image = NewMagickWand();

    // Load image
    MagickReadImage(image,"bar.jpg");

    // Set Colors
    PixelSetColor(target,"rgb(65535, 65535, 65535)");
    PixelSetColor(fill,"rgb(53456, 35209, 30583)");

    // Apply effect(wand,0.40);
    MagickOpaquePaintImage(image,target,fill,fuzz,MagickFalse);

    // Save image
    MagickWriteImages(image,"foo2.jpg",MagickTrue);

    // Clean up
    image=DestroyMagickWand(image);
    MagickWandTerminus();

    return 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM