- Namespace
- Statiq
.Images - Interfaces
- Base Types
-
- object
- Module
- ParallelSyncModule
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 |
void |
Called after each module execution.
Inherited from Module
|
AfterExecutionAsync |
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 |
void |
Called before each module execution.
Inherited from Module
|
BeforeExecutionAsync |
Task |
Called before each module execution.
Inherited from Module
|
BlackWhite |
MutateImage |
Applies black and white toning to the image.
|
Brightness |
MutateImage |
Brightens the image.
|
Contrast |
MutateImage |
Adjusts the contrast of the image.
|
ExecuteAsync |
Task |
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 |
Task |
Executes the module once for all input documents.
Inherited from ParallelSyncModule
|
ExecuteInput |
IEnumerable |
|
ExecuteInputAsync |
Task |
Executes the module.
Inherited from ParallelSyncModule
|
Finally |
void |
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
|
FinallyAsync |
Task |
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
|
Hue |
MutateImage |
Sets the hue of the image using
0 to 360 degree values.
|
Opacity |
MutateImage |
Multiplies the alpha component of the image.
|
Operation |
MutateImage |
Allows you to specify your own ImageSharp operation.
|
OutputAs |
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 |
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 |
MutateImage |
Saturates the image.
|
SetPrefix |
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 |
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 |
MutateImage |
Apply vignette processing to the image with specific color, e.g.
Vignette(Color.AliceBlue) .
|