How to adjust jpeg quality with Magick.Net

最后都变了- 提交于 2019-12-05 17:51:35

问题


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()?


回答1:


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



来源:https://stackoverflow.com/questions/19884486/how-to-adjust-jpeg-quality-with-magick-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!