MutateImage Class
This module manipulates images by applying a variety of operations.
Namespace
Statiq.Images
Interfaces
Base Types
graph BT Type-->Base0["ParallelSyncModule"] click Base0 "/api/Statiq.Common/ParallelSyncModule" Base0-->Base1["Module"] click Base1 "/api/Statiq.Common/Module" Base1-->Base2["object"] Type-.->Interface0["IModule"] click Interface0 "/api/Statiq.Common/IModule" Type-.->Interface1["IParallelModule"] click Interface1 "/api/Statiq.Common/IParallelModule" Type["MutateImage"] class Type type-node

Syntax

public class MutateImage : ParallelSyncModule, IModule, IParallelModule

Remarks

This module manipulates images by applying operations such as resizing, darken/lighten, etc. This image module does not modify your original images in any way. It will create a copy of your images and produce images in the same image format as the original. It relies on other modules such as ReadFiles to read the actual images as input and WriteFiles to write images to disk.

Pipelines.Add("Images",
  ReadFiles("*")
    .Where(x => new[] { ".jpg", ".jpeg", ".gif", ".png"}.Contains(x.Path.Extension)),
  Image()
    .SetJpegQuality(100).Resize(400,209).SetSuffix("-thumb"),
  WriteFiles("*")
);

It will produce image with similar file name as the original image with addition of suffix indicating operations that have performed, e.g. "hello-world.jpg" can result in "hello-world-w100.jpg". The module allows you to perform more than one set of processing instructions by using the fluent property And.

Pipelines.Add("Images",
  ReadFiles("*")
    .Where(x => new[] { ".jpg", ".jpeg", ".gif", ".png"}.Contains(x.Path.Extension)),
  Image()
    .SetJpegQuality(100).Resize(400, 209).SetSuffix("-thumb")
    .And()
    .SetJpegQuality(70).Resize(400*2, 209*2).SetSuffix("-medium"),
  WriteFiles("*")
);

The above configuration produces two set of new images, one with a "-thumb" suffix and the other with a "-medium" suffix.

Constructors

Name Summary
MutateImage() Process images in the content of the input document.

Properties

Name Property Type Summary
Parallel bool
Indicates whether documents will be processed by this module in parallel.
Inherited from ParallelSyncModule

Methods

Name Return Value Summary
AfterExecution(IExecutionContext, ExecutionOutputs) void
Called after each module execution.
Inherited from Module
AfterExecutionAsync(IExecutionContext, ExecutionOutputs) Task
Called after each module execution.
Inherited from Module
And() MutateImage
Mark the beginning of another set of processing instructions to be applied to the images.
BeforeExecution(IExecutionContext) void
Called before each module execution.
Inherited from Module
BeforeExecutionAsync(IExecutionContext) Task
Called before each module execution.
Inherited from Module
BlackWhite() MutateImage
Applies black and white toning to the image.
Brightness(float) MutateImage
Brightens the image.
Contrast(float) MutateImage
Adjusts the contrast of the image.
ExecuteAsync(IExecutionContext) Task<IEnumerable<IDocument>>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
ExecuteContextAsync(IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module once for all input documents.
Inherited from ParallelSyncModule
ExecuteInput(IDocument, IExecutionContext) IEnumerable<IDocument>
ExecuteInputAsync(IDocument, IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module.
Inherited from ParallelSyncModule
Finally(IExecutionContext) void
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
FinallyAsync(IExecutionContext) Task
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
Hue(float) MutateImage
Sets the hue of the image using 0 to 360 degree values.
Opacity(float) MutateImage
Multiplies the alpha component of the image.
Operation(Func<IImageProcessingContext, IImageProcessingContext>, Func<NormalizedPath, NormalizedPath>) MutateImage
Allows you to specify your own ImageSharp operation.
OutputAs(Action<Image<Rgba32>, Stream>, Func<NormalizedPath, NormalizedPath>) MutateImage
Allows you to specify an alternate output format for the image. For example, you might use this if you want to full specify the encoder and it's properties. This will override the default behavior of outputting the image as the same format.
OutputAsBmp() MutateImage
Outputs the image as BMP. This will override the default behavior of outputting the image as the same format.
OutputAsGif() MutateImage
Outputs the image as GIF. This will override the default behavior of outputting the image as the same format.
OutputAsJpeg() MutateImage
Outputs the image as JPEG. This will override the default behavior of outputting the image as the same format.
OutputAsPng() MutateImage
Outputs the image as PNG. This will override the default behavior of outputting the image as the same format.
OutputAsWebp() MutateImage
Outputs the image as WebP. This will override the default behavior of outputting the image as the same format.
Resize(int?, int?, AnchorPositionMode, ResizeMode) MutateImage
Resizes the image to a certain width and height. No resizing will be performed if both width and height are set to null.
Saturate(float) MutateImage
Saturates the image.
SetPrefix(string) MutateImage
Set the prefix of the generated image, e.g. SetPrefix("medium-") will transform original filename "hello-world.jpg" to "medium-hello-world.jpg".
SetSuffix(string) MutateImage
Set the suffix of the generated image, e.g. SetSuffix("-medium") will transform original filename "hello-world.jpg" to "hello-world-medium.jpg".
Vignette(Color) MutateImage
Apply vignette processing to the image with specific color, e.g. Vignette(Color.AliceBlue).

Extension Methods