Question

I am trying to set the image quality of two images appended to one another to 10% and resize the images to 40x40.

using (var images = new MagickImageCollection {designFile, swatchFile})
{
    MagickImage sprite = images.AppendHorizontally();
    sprite.Format = MagickFormat.Jpeg;
    sprite.SetOption(MagickFormat.Jpeg, "quality", "10%");
    sprite.SetOption(MagickFormat.Jpeg, "size", "40x40"); ;

    sprite.Write(spriteFile);
}

Unfortunately the SetOption and Format calls don't seem to be affecting the file that is written to sprite.Write()?

Was it helpful?

Solution

The method SetOption is the same as -define in ImageMagick. And this method will be renamed to SetDefine in the next release. The following resizes your image to 40x40 and uses a quality of 10%.

using (MagickImage sprite = images.AppendHorizontally())
{
    sprite.Format = MagickFormat.Jpeg;
    sprite.Quality = 10;
    sprite.Resize(40, 40);
    sprite.Write(spriteFile);
}

If you need more help feel free to post another question here: https://magick.codeplex.com/discussions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top