DEXTUpload.NET Professional
menu toggleReferences > DEXTUpload.NET > ImageProc

DEXTUpload.NET
Class ImageProc

The minimum supported version
5.0.0.0
The minimum support environment
.NET Framework 4.0
Explanation

DEXTUpload.NET Professional component product provides a utility class that uses the Windows GDI+ to support a simple image processing in a Web application environment.

Because the "ImageProc" class uses the GDI+, in the case of a server, it is possible to operate only in GDI+ supported OS.

Note) The "ImageProc" class, because it supports only the image processing of the basic level, does not provide complex calculations or high-speed processing. Therefore, when the high level of processing is required, it is recommended that you use a professional library of image.

var source = new FileInfo("source.jpg");

// Get the image object.
var img = ImageProc.GetImage(source);

// Get the metadata.
var metadata = ImageProc.GetMetadata(source);

// Save it as a file.
ImageProc.SaveImage(img, new FileInfo("output.jpg"), new ImageSaveOption { IsOverwrite = true });

// Convert JPEG file to PNG file and save it.
ImageProc.ConvertImage(source, new FileInfo("output.png"), new ImageSaveOption { OutputFormat = ImageFormat.Png });

// Resize the image.
var img01 = ImageProc.Resize(img, new ResizingOption { Width = 50, Height = 20, Unit = ImageResizeUnit.Percentage });

// Fit the image.
var img02 = ImageProc.Fit(img, new FittingOption { Width = 100, Height = 200, Fit = ImageFitOption.Uniform });
Type
public static class ImageProc
Methods

GetImage

  • Reads the image file and returns a generated "System.Drawing.Image" object.

  • Type

    public static Image GetImage(string sourcePath)
    public static Image GetImage(FileInfo source)
  • Parameters

    Name Type Explanation
    sourcePath System.String The path(a sub-path of Web application or a physical path of the local operation system) of the image file.
    source System.IO.FileInfo An object with the image information.
  • Return

    A "System.Drawing.Image" object with the image information.

GetMetadata

  • Extracts a metadata from the image and returns it.

    The metadata is supported from TIFF, JPEG, PNG, EXIF ​​image format. Other formats are not supported.

  • Type

    public static Metadata GetMetadata(Image imgSource)
    public static Metadata GetMetadata(FileInfo source)
    public static Metadata GetMetadata(string sourcePath)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object to extract the metadata.
    source System.IO.FileInfo An object with the path information of the image file to extract the metadata.
    sourcePath System.String The path(a sub-path of Web application or a physical path of the local operation system) of the image file to extract metadata.
  • Return

    A "DEXTUpload.NET.Metadata" object that has extracted metadata from the image .

SaveImage

  • Saves a "System.Drawing.Image" object in different image format.

  • Type

    public static string SaveImage(Image imgSource, FileInfo target, ImageSaveOption option)
    public static string SaveImage(Image imgSource, string targetPath, ImageSaveOption option)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object to be saved in other image format.
    target System.IO.FileInfo An object with the path information of the destination.
    targetPath System.String The path(a sub-path of Web application or a physical path of the local operation system) of the file to be saved.
    option DEXTUpload.NET.ImageSaveOption An object with the information of the options of saving an image file.
  • Return

    The phyical path of the saved image file on the local operating system.

ConvertImage

  • Saves the original image file in a different image format.

  • Type

    public static string ConvertImage(FileInfo source, FileInfo target, ImageSaveOption option)
    public static string ConvertImage(string sourcePath, string targetPath, ImageSaveOption option)
  • Parameters

    Name Type Explanation
    source System.IO.FileInfo An object with the path information of the original image file.
    target System.IO.FileInfo An object with the path information of the destination.
    sourcePath System.String The path(a sub-path of Web application or a physical path of the local operation system) of the original image file.
    targetPath System.String The path(a sub-path of Web application or a physical path of the local operation system) of the file to be saved.
    option DEXTUpload.NET.ImageSaveOption An object with the information of the options of saving a image file.
  • Return

    The physical path of the saved image file on the local operating system.

Overlay

  • Generates an image by overlaying another image or text on the original image with.

  • Type

    public static Image Overlay(Image imgSource, Image imgTarget, OverlayOption option)
    public static Image Overlay(FileInfo source, FileInfo target, OverlayOption option)
    public static Image Overlay(string sourcePath, string targetPath, OverlayOption option)
    public static Image Overlay(Image imgSource, string text, Font font, Color fontColor, OverlayOption option)
    public static Image Overlay(FileInfo source, string text, Font font, Color fontColor, OverlayOption option)
    public static Image Overlay(string sourcePath, string text, Font font, Color fontColor, OverlayOption option)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image The original image object.
    imgTarget System.Drawing.Image The overlay image object.
    source System.IO.FileInfo An object with the path information of the original image.
    target System.IO.FileInfo An object with the path information of the overlay image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    targetPath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the overlay image file.
    text System.String A text to overlay.
    font System.Drawing.Font An object with a font style information of the text.
    fontColor System.Drawing.Color An object with the color information of the text.
    option DEXTUpload.NET.OverlayOption An object with the overlay processing information.
  • Return

    An overlayed "System.Drawing.Image" object.

Pattern

  • Generates an image overlayed by using as a pattern image or text pattern on the original image.

  • Type

    public static Image Pattern(Image imgSource, Image imgPattern, PatternOption option)
    public static Image Pattern(FileInfo source, FileInfo pattern, PatternOption option)
    public static Image Pattern(string sourcePath, string patternPath, PatternOption option)
    public static Image Pattern(Image imgSource, string text, Font font, Color fontColor, PatternOption option)
    public static Image Pattern(FileInfo source, string text, Font font, Color fontColor, PatternOption option)
    public static Image Pattern(string sourcePath, string text, Font font, Color fontColor, PatternOption option)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    imgPattern System.Drawing.Image An image object used as a pattern.
    source System.IO.FileInfo An object with the path information of the original image.
    pattern System.IO.FileInfo An object with the path information of the image to be used as a pattern.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    patternPath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the image to be used as a pattern.
    text System.String The text to use as a pattern.
    font System.Drawing.Font An object with a font style information of the text.
    fontColor System.Drawing.Color An object with the color information of the text.
    option DEXTUpload.NET.PatternOption An object with the information to overlay pattern.
  • Return

    A "System.Drawing.Image" object that overlayed with pattern.

Resize

  • Generates a resized image.

  • Type

    public static Image Resize(Image imgSource, ResizingOption option)
    public static Image Resize(FileInfo source, ResizingOption option)
    public static Image Resize(string sourcePath, ResizingOption option)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    option DEXTUpload.NET.ResizingOption An object with the information of the resizing option.
  • Return

    A resized "System.Drawing.Image" object.

Fit

  • Generates an image by fitting the original image into the specified frame.

  • Type

    public static Image Fit(Image imgSource, FittingOption option)
    public static Image Fit(FileInfo source, FittingOption option)
    public static Image Fit(string sourcePath, FittingOption option)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    option DEXTUpload.NET.FittingOption An object with the information of the fitting option.
  • Return

    A fitted "System.Drawing.Image" object.

Rotate

  • Generates an image by rotating the original image.

  • Type

    public static Image Rotate(Image imgSource, double degree, Color backgroundColor)
    public static Image Rotate(FileInfo source, double degree, Color backgroundColor)
    public static Image Rotate(string sourcePath, double degree, Color backgroundColor)
    public static Image Rotate(Image imgSource, RotationMethod method)
    public static Image Rotate(FileInfo source, RotationMethod method)
    public static Image Rotate(string sourcePath, RotationMethod method)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    degree System.Double The angle to rotate the image.
    backgroundColor System.Drawing.Color An object that represents the color to fill the blank space occurring after rotating the image.
    method DEXTUpload.NET.RotationMethod An enumeration value of indicating the rotation method.
  • Return

    A rotated "System.Drawing.Image" object.

Flip

  • Generates an image obtained by flipping the original image with respect to coordinate axes.

  • Type

    public static Image Flip(Image imgSource, FlipMethod method)
    public static Image Flip(FileInfo source, FlipMethod method)
    public static Image Flip(string sourcePath, FlipMethod method)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    method DEXTUpload.NET.FlipMethod An enumeration value that represents how to flip the image.
  • Return

    A flipped "System.Drawing.Image" object.

Crop

  • Generates new image by cutting(cropping) the original image.

  • Type

    public static Image Crop(Image imgSource, int x, int y, int width, int height)
    public static Image Crop(FileInfo source, int x, int y, int width, int height)
    public static Image Crop(string sourcePath, int x, int y, int width, int height)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    x System.Int32 The specified position of the x-axis of the rectangular area to be cut.
    y System.Int32 The specified position of the y-axis of the rectangular area to be cut
    width System.Int32 The specified horizontal length of the crop rectangle.
    height System.Int32 The specified vertical length of the crop rectangle.
  • Return

    A "System.Drawing.Image" objects that were cut.

HasAnimationFrame (supported from 5.2.0.0 version)

  • Returns whether or not the original image has a frame information of each time.

  • Type

    public static bool HasAnimationFrame(Image imgSource)
    public static bool HasAnimationFrame(FileInfo source)
    public static bool HasAnimationFrame(string sourcePath)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file
  • Return

    true if the image has a frame information for each time, or is "false".

GetAnimationFrameCount (supported from 5.2.0.0 version)

  • Returns the number of frames if the original image has a frame information for each time.

    If it does not have a frame information for each time, the method throws an error, so you should confirm that the image has a frame information by using the "HasAnimationFrame" method.

  • Type

    public static int GetAnimationFrameCount(Image imgSource)
    public static int GetAnimationFrameCount(FileInfo source)
    public static int GetAnimationFrameCount(string sourcePath)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
  • Return

    The number of frames.

GetAnimationFrame (supported from 5.2.0.0 version)

  • Returns a "System.Drawing.Image" object corresponding to the frame number if the original image has a frame information.

    For animated GIF file, it can be used to extract a specific frame.

  • Type

    public static Image GetAnimationFrame(Image imgSource, int frameIndex)
    public static Image GetAnimationFrame(FileInfo source, int frameIndex)
    public static Image GetAnimationFrame(string sourcePath, int frameIndex)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    frameIndex System.Int32 A frame number to be extracted.
  • Return

    A extracted "System.Drawing.Image" object.

ExtractAnimationFrame (supported from 5.2.0.0 version)

  • Create an image file corresponding to the frame number if the original image has a frame information.

    For animated GIF file, it can be used to extract a specific frame.

  • Type

    public static string ExtractAnimationFrame(Image imgSource, int frameIndex, FileInfo target, bool overwrite option)
    public static string ExtractAnimationFrame(FileInfo source, int frameIndex, FileInfo target, bool overwrite option)
    public static string ExtractAnimationFrame(string sourcePath, int frameIndex, FileInfo target, bool overwrite option)
    public static string ExtractAnimationFrame(Image imgSource, int frameIndex, string targetPath, bool overwrite option)
    public static string ExtractAnimationFrame(FileInfo source, int frameIndex, string targetPath, bool overwrite option)
    public static string ExtractAnimationFrame(string sourcePath, int frameIndex, string targetPath, bool overwrite option)
  • Parameters

    Name Type Explanation
    imgSource System.Drawing.Image An object of the original image.
    source System.IO.FileInfo An object with the path information of the original image.
    sourcePath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the original image file.
    frameIndex System.Int32 A frame number to be extracted.
    target System.IO.FileInfo An object with the path information of the file to be saved.
    targetPath System.String The path(a sub-path of the Web applications or a physical path on the local operating system) of the file to be saved.
    overwrite System.Boolean When saving the file, if there is a file of the same name previously, indicate whether you want to overwrite.
  • Return

    The path(a physical path on the local operation system) of the image with extracted frame information.