Automatically changing the image quality in Wyam

Published on Sunday, April 28, 2019

After moving to a Wyam based blog I encountered problem in the documentation of the Wyam.Images module when trying to change the image quality for the copied images.

During some searching and some source-code reading I found that the documentation is no longer valid and that the new way of changing the jpeg output quality can be done as following.

using SixLabors.ImageSharp.Formats.Jpeg;

Pipelines.Add(
    "Images",
    Image()
        .OutputAs(
            (image, stream) => image.Save(stream, new JpegEncoder() {
                Quality = 75,
            }),
            path => path.ChangeExtension(".75.jpeg")
        ),
);
comments powered by Disqus