C# Class ImageProcessor.ImageFactory

Encapsulates methods for processing image files in a fluent manner.
Inheritance: IDisposable
ファイルを表示 Open project: JimBobSquarePants/ImageProcessor Class Usage Examples

Private Properties

Property Type Description
ClearExif void

Public Methods

Method Description
Alpha ( int percentage ) : ImageFactory

Changes the opacity of the current image.

AutoRotate ( ) : ImageFactory

Performs auto-rotation to ensure that EXIF defined rotation is reflected in the final image.

BackgroundColor ( Color color ) : ImageFactory

Changes the background color of the current image.

BitDepth ( long bitDepth ) : ImageFactory

Alters the bit depth of the current image. This can only be used to change the bit depth of images that can be saved by System.Drawing with different bit depths such as TIFF.

Brightness ( int percentage ) : ImageFactory

Changes the brightness of the current image.

Constrain ( Size size ) : ImageFactory

Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio.

Contrast ( int percentage ) : ImageFactory

Changes the contrast of the current image.

Crop ( CropLayer cropLayer ) : ImageFactory

Crops the current image to the given location and size.

Crop ( Rectangle rectangle ) : ImageFactory

Crops the current image to the given location and size.

DetectEdges ( IEdgeFilter filter, bool greyscale = true ) : ImageFactory

Detects the edges in the current image.

Dispose ( ) : void

Disposes the object and frees resources for the Garbage Collector.

EntropyCrop ( byte threshold = 128 ) : ImageFactory

Crops an image to the area of greatest entropy.

Filter ( IMatrixFilter matrixFilter ) : ImageFactory

Applies a filter to the current image. Use the MatrixFilters class to assign the correct filter.

Flip ( bool flipVertically = false, bool flipBoth = false ) : ImageFactory

Flips the current image either horizontally or vertically.

Format ( ISupportedImageFormat format ) : ImageFactory

Sets the output format of the current image to the matching T:System.Drawing.Imaging.ImageFormat.

Gamma ( float value ) : ImageFactory

Adjust the gamma (intensity of the light) component of the given image.

GaussianBlur ( GaussianLayer gaussianLayer ) : ImageFactory

Uses a Gaussian kernel to blur the current image.

GaussianBlur ( int size ) : ImageFactory

Uses a Gaussian kernel to blur the current image.

The sigma and threshold values applied to the kernel are 1.4 and 0 respectively.

GaussianSharpen ( GaussianLayer gaussianLayer ) : ImageFactory

Uses a Gaussian kernel to sharpen the current image.

GaussianSharpen ( int size ) : ImageFactory

Uses a Gaussian kernel to sharpen the current image.

The sigma and threshold values applied to the kernel are 1.4 and 0 respectively.

Halftone ( bool comicMode = false ) : ImageFactory

Converts the current image to a CMYK halftone representation of that image.

Hue ( int degrees, bool rotate = false ) : ImageFactory

Alters the hue of the current image changing the overall color.

ImageFactory ( bool preserveExifData = false ) : System

Initializes a new instance of the ImageFactory class.

ImageFactory ( bool preserveExifData, bool fixGamma ) : System

Initializes a new instance of the ImageFactory class.

Load ( Stream stream ) : ImageFactory

Loads the image to process. Always call this method first.

Load ( byte bytes ) : ImageFactory

Loads the image to process from an array of bytes. Always call this method first.

Load ( string imagePath ) : ImageFactory

Loads the image to process. Always call this method first.

Mask ( Image imageMask, Point point = null ) : ImageFactory

Applies the given image mask to the current image.

Overlay ( ImageProcessor.Imaging.ImageLayer imageLayer ) : ImageFactory

Adds a image overlay to the current image.

Pixelate ( int pixelSize, Rectangle rectangle = null ) : ImageFactory

Pixelates an image with the given size.

Quality ( int percentage ) : ImageFactory

Alters the output quality of the current image. This method will only effect the output quality of jpeg images

ReplaceColor ( Color target, Color replacement, int fuzziness ) : ImageFactory

Replaces a color within the current image.

Reset ( ) : ImageFactory

Resets the current image to its original loaded state.

Resize ( ResizeLayer resizeLayer ) : ImageFactory

Resizes the current image to the given dimensions.

Resize ( Size size ) : ImageFactory

Resizes the current image to the given dimensions.

Resolution ( int horizontal, int vertical, PropertyTagResolutionUnit unit = PropertyTagResolutionUnit.Inch ) : ImageFactory

Sets the resolution of the image. This method sets both the bitmap data and EXIF resolution if available.

Rotate ( float degrees ) : ImageFactory

Rotates the current image by the given angle.

RotateBounded ( float degrees, bool keepSize = false ) : ImageFactory

Rotates the image without expanding the canvas to fit the image.

RoundedCorners ( RoundedCornerLayer roundedCornerLayer ) : ImageFactory

Adds rounded corners to the current image.

RoundedCorners ( int radius ) : ImageFactory

Adds rounded corners to the current image.

Saturation ( int percentage ) : ImageFactory

Changes the saturation of the current image.

Save ( Stream stream ) : ImageFactory

Saves the current image to the specified output stream.

Save ( string filePath ) : ImageFactory

Saves the current image to the specified file path. If the extension does not match the correct extension for the current format it will be replaced by the correct default value.

Tint ( Color color ) : ImageFactory

Tints the current image with the given color.

Vignette ( Color color = null ) : ImageFactory

Adds a vignette image effect to the current image.

Watermark ( ImageProcessor.Imaging.TextLayer textLayer ) : ImageFactory

Adds a text based watermark to the current image.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Disposes the object and frees resources for the Garbage Collector.

Private Methods

Method Description
ClearExif ( Image image ) : void

Clears any EXIF metadata from the image

Method Details

Alpha() public method

Changes the opacity of the current image.
public Alpha ( int percentage ) : ImageFactory
percentage int /// The percentage by which to alter the images opacity. /// Any integer between 0 and 100. ///
return ImageFactory

AutoRotate() public method

Performs auto-rotation to ensure that EXIF defined rotation is reflected in the final image.
public AutoRotate ( ) : ImageFactory
return ImageFactory

BackgroundColor() public method

Changes the background color of the current image.
public BackgroundColor ( Color color ) : ImageFactory
color Color /// The to paint the image with. ///
return ImageFactory

BitDepth() public method

Alters the bit depth of the current image. This can only be used to change the bit depth of images that can be saved by System.Drawing with different bit depths such as TIFF.
public BitDepth ( long bitDepth ) : ImageFactory
bitDepth long A value over 0.
return ImageFactory

Brightness() public method

Changes the brightness of the current image.
public Brightness ( int percentage ) : ImageFactory
percentage int /// The percentage by which to alter the images brightness. /// Any integer between -100 and 100. ///
return ImageFactory

Constrain() public method

Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio.
public Constrain ( Size size ) : ImageFactory
size System.Drawing.Size /// The containing the maximum width and height to set the image to. ///
return ImageFactory

Contrast() public method

Changes the contrast of the current image.
public Contrast ( int percentage ) : ImageFactory
percentage int /// The percentage by which to alter the images contrast. /// Any integer between -100 and 100. ///
return ImageFactory

Crop() public method

Crops the current image to the given location and size.
public Crop ( CropLayer cropLayer ) : ImageFactory
cropLayer ImageProcessor.Imaging.CropLayer /// The containing the coordinates and mode to crop the image with. ///
return ImageFactory

Crop() public method

Crops the current image to the given location and size.
public Crop ( Rectangle rectangle ) : ImageFactory
rectangle System.Drawing.Rectangle /// The containing the coordinates to crop the image to. ///
return ImageFactory

DetectEdges() public method

Detects the edges in the current image.
public DetectEdges ( IEdgeFilter filter, bool greyscale = true ) : ImageFactory
filter IEdgeFilter /// The to detect edges with. ///
greyscale bool /// Whether to convert the image to greyscale first - Defaults to true. ///
return ImageFactory

Dispose() public method

Disposes the object and frees resources for the Garbage Collector.
public Dispose ( ) : void
return void

Dispose() protected method

Disposes the object and frees resources for the Garbage Collector.
protected Dispose ( bool disposing ) : void
disposing bool If true, the object gets disposed.
return void

EntropyCrop() public method

Crops an image to the area of greatest entropy.
public EntropyCrop ( byte threshold = 128 ) : ImageFactory
threshold byte /// The threshold in bytes to control the entropy. ///
return ImageFactory

Filter() public method

Applies a filter to the current image. Use the MatrixFilters class to assign the correct filter.
public Filter ( IMatrixFilter matrixFilter ) : ImageFactory
matrixFilter IMatrixFilter /// The of the filter to add to the image. ///
return ImageFactory

Flip() public method

Flips the current image either horizontally or vertically.
public Flip ( bool flipVertically = false, bool flipBoth = false ) : ImageFactory
flipVertically bool /// Whether to flip the image vertically. ///
flipBoth bool /// Whether to flip the image both vertically and horizontally. ///
return ImageFactory

Format() public method

Sets the output format of the current image to the matching T:System.Drawing.Imaging.ImageFormat.
public Format ( ISupportedImageFormat format ) : ImageFactory
format ISupportedImageFormat The . to set the image to.
return ImageFactory

Gamma() public method

Adjust the gamma (intensity of the light) component of the given image.
public Gamma ( float value ) : ImageFactory
value float /// The value to adjust the gamma by (typically between .2 and 5). ///
return ImageFactory

GaussianBlur() public method

Uses a Gaussian kernel to blur the current image.
public GaussianBlur ( GaussianLayer gaussianLayer ) : ImageFactory
gaussianLayer ImageProcessor.Imaging.GaussianLayer /// The for applying sharpening and /// blurring methods to an image. ///
return ImageFactory

GaussianBlur() public method

Uses a Gaussian kernel to blur the current image.

The sigma and threshold values applied to the kernel are 1.4 and 0 respectively.

public GaussianBlur ( int size ) : ImageFactory
size int /// The size to set the Gaussian kernel to. ///
return ImageFactory

GaussianSharpen() public method

Uses a Gaussian kernel to sharpen the current image.
public GaussianSharpen ( GaussianLayer gaussianLayer ) : ImageFactory
gaussianLayer ImageProcessor.Imaging.GaussianLayer /// The for applying sharpening and /// blurring methods to an image. ///
return ImageFactory

GaussianSharpen() public method

Uses a Gaussian kernel to sharpen the current image.

The sigma and threshold values applied to the kernel are 1.4 and 0 respectively.

public GaussianSharpen ( int size ) : ImageFactory
size int /// The size to set the Gaussian kernel to. ///
return ImageFactory

Halftone() public method

Converts the current image to a CMYK halftone representation of that image.
public Halftone ( bool comicMode = false ) : ImageFactory
comicMode bool /// Whether to trace over the current image and add borders to add a comic book effect. ///
return ImageFactory

Hue() public method

Alters the hue of the current image changing the overall color.
public Hue ( int degrees, bool rotate = false ) : ImageFactory
degrees int /// The angle by which to alter the images hue. /// Any integer between 0 and 360. ///
rotate bool /// Whether to rotate the hue of the current image altering each color ///
return ImageFactory

ImageFactory() public method

Initializes a new instance of the ImageFactory class.
public ImageFactory ( bool preserveExifData = false ) : System
preserveExifData bool /// Whether to preserve exif metadata. Defaults to false. ///
return System

ImageFactory() public method

Initializes a new instance of the ImageFactory class.
public ImageFactory ( bool preserveExifData, bool fixGamma ) : System
preserveExifData bool /// Whether to preserve exif metadata. Defaults to false. ///
fixGamma bool /// Whether to fix the gamma component of the image. Defaults to true. ///
return System

Load() public method

Loads the image to process. Always call this method first.
public Load ( Stream stream ) : ImageFactory
stream Stream /// The containing the image information. ///
return ImageFactory

Load() public method

Loads the image to process from an array of bytes. Always call this method first.
public Load ( byte bytes ) : ImageFactory
bytes byte /// The containing the image information. ///
return ImageFactory

Load() public method

Loads the image to process. Always call this method first.
public Load ( string imagePath ) : ImageFactory
imagePath string The absolute path to the image to load.
return ImageFactory

Mask() public method

Applies the given image mask to the current image.
public Mask ( Image imageMask, Point point = null ) : ImageFactory
imageMask Image /// The image containing the mask to apply. ///
point Point /// The to place the mask if it not the same dimensions as the original image. /// If no position is set, the mask will be centered within the image. ///
return ImageFactory

Overlay() public method

Adds a image overlay to the current image.
public Overlay ( ImageProcessor.Imaging.ImageLayer imageLayer ) : ImageFactory
imageLayer ImageProcessor.Imaging.ImageLayer /// The containing the properties necessary to add /// the image overlay to the image. ///
return ImageFactory

Pixelate() public method

Pixelates an image with the given size.
public Pixelate ( int pixelSize, Rectangle rectangle = null ) : ImageFactory
pixelSize int /// The size of the pixels to create.
rectangle System.Drawing.Rectangle /// The area in which to pixelate the image. If not set, the whole image is pixelated. ///
return ImageFactory

Quality() public method

Alters the output quality of the current image. This method will only effect the output quality of jpeg images
public Quality ( int percentage ) : ImageFactory
percentage int A value between 1 and 100 to set the quality to.
return ImageFactory

ReplaceColor() public method

Replaces a color within the current image.
public ReplaceColor ( Color target, Color replacement, int fuzziness ) : ImageFactory
target Color /// The target . ///
replacement Color /// The replacement . ///
fuzziness int /// A value between 0 and 128 with which to alter the target detection accuracy. ///
return ImageFactory

Reset() public method

Resets the current image to its original loaded state.
public Reset ( ) : ImageFactory
return ImageFactory

Resize() public method

Resizes the current image to the given dimensions.
public Resize ( ResizeLayer resizeLayer ) : ImageFactory
resizeLayer ImageProcessor.Imaging.ResizeLayer /// The containing the properties required to resize the image. ///
return ImageFactory

Resize() public method

Resizes the current image to the given dimensions.
public Resize ( Size size ) : ImageFactory
size System.Drawing.Size /// The containing the width and height to set the image to. ///
return ImageFactory

Resolution() public method

Sets the resolution of the image. This method sets both the bitmap data and EXIF resolution if available.
public Resolution ( int horizontal, int vertical, PropertyTagResolutionUnit unit = PropertyTagResolutionUnit.Inch ) : ImageFactory
horizontal int The horizontal resolution.
vertical int The vertical resolution.
unit PropertyTagResolutionUnit /// The unit of measure for the horizontal resolution and the vertical resolution. /// Defaults to inches ///
return ImageFactory

Rotate() public method

Rotates the current image by the given angle.
public Rotate ( float degrees ) : ImageFactory
degrees float /// The angle at which to rotate the image in degrees. ///
return ImageFactory

RotateBounded() public method

Rotates the image without expanding the canvas to fit the image.
public RotateBounded ( float degrees, bool keepSize = false ) : ImageFactory
degrees float /// The angle at which to rotate the image in degrees. ///
keepSize bool /// Whether to keep the original image dimensions. /// /// If set to true, the image is zoomed to fit the bounding area. /// /// /// If set to false, the area is cropped to fit the rotated image. /// ///
return ImageFactory

RoundedCorners() public method

Adds rounded corners to the current image.
public RoundedCorners ( RoundedCornerLayer roundedCornerLayer ) : ImageFactory
roundedCornerLayer ImageProcessor.Imaging.RoundedCornerLayer /// The containing the properties to round corners on the image. ///
return ImageFactory

RoundedCorners() public method

Adds rounded corners to the current image.
public RoundedCorners ( int radius ) : ImageFactory
radius int /// The radius at which the corner will be rounded. ///
return ImageFactory

Saturation() public method

Changes the saturation of the current image.
public Saturation ( int percentage ) : ImageFactory
percentage int /// The percentage by which to alter the images saturation. /// Any integer between -100 and 100. ///
return ImageFactory

Save() public method

Saves the current image to the specified output stream.
public Save ( Stream stream ) : ImageFactory
stream Stream /// The to save the image information to. ///
return ImageFactory

Save() public method

Saves the current image to the specified file path. If the extension does not match the correct extension for the current format it will be replaced by the correct default value.
public Save ( string filePath ) : ImageFactory
filePath string The path to save the image to.
return ImageFactory

Tint() public method

Tints the current image with the given color.
public Tint ( Color color ) : ImageFactory
color Color /// The to tint the image with. ///
return ImageFactory

Vignette() public method

Adds a vignette image effect to the current image.
public Vignette ( Color color = null ) : ImageFactory
color Color /// The to tint the image with. Defaults to black. ///
return ImageFactory

Watermark() public method

Adds a text based watermark to the current image.
public Watermark ( ImageProcessor.Imaging.TextLayer textLayer ) : ImageFactory
textLayer ImageProcessor.Imaging.TextLayer /// The containing the properties necessary to add /// the text based watermark to the image. ///
return ImageFactory