Resize Statiq Images on Build

Published on Thursday, 25 March 2021

I was after a smart way to process my images inside Statiq so they are a uniform size, without having to use a 3rd party image manipulation program. This allows me to keep the process in one place and I won't forget about it!

After some digging around, I found this way on Github which solves my problem.

What the following does is add a new pipeline called "ResizeTitleImages", search for images file types inside the blog folder, and resize them twice with the two different output sizes.

public class Program
    private static async Task<int> Main(string[] args) =>
        await Bootstrapper
            .BuildPipeline("ResizeTitleImages", builder =>
                builder.WithInputModules(new MutateImage()
                    .Resize(960, 720).OutputAsJpeg()
                    .Resize(1920, 1440).OutputAsJpeg()