Class ImageUtils

Summary description for wwImaging.

System.Object
  Westwind.Utilities.ImageUtils
public static class ImageUtils : object

Class Members

MemberDescription

AdjustImageToRatio

Adjusts an image to a specific aspect ratio by clipping from the center outward - essentially capturing the center to fit the width/height of the aspect ratio.

public static Bitmap AdjustImageToRatio(Stream imageStream,     decimal ratio,     int resizeWidth,     int resizeHeight)

public static Bitmap AdjustImageToRatio(Byte[] imageContent,     decimal ratio,     int resizeWidth,     int resizeHeight)

GetExtensionFromMediaType

Returns a file extension for a media type/content type.

public static string GetExtensionFromMediaType(string mediaType)

GetImageFormatFromFilename

Tries to return an image format

public static ImageFormat GetImageFormatFromFilename(string filename)

GetImageMediaTypeFromFilename

Returns the image media type for a give file extension based on a filename or url passed in.

public static string GetImageMediaTypeFromFilename(string file)

NormalizeJpgImageRotation

If the image contains image rotation Exif data, apply the image rotation and remove the Exif data. Optionally also allows for image resizing in the same operation.

public static void NormalizeJpgImageRotation(string imageFile,     int imageQuality,     int width,     int height)

ResizeImage

Creates a resized bitmap from an existing image on disk. Resizes the image by creating an aspect ratio safe image. Image is sized to the larger size of width height and then smaller size is adjusted by aspect ratio.

Image is returned as Bitmap - call Dispose() on the returned Bitmap object

public static Bitmap ResizeImage(string filename,     int width,     int height,     InterpolationMode mode)

public static Bitmap ResizeImage(Byte[] data,     int width,     int height,     InterpolationMode mode)

public static bool ResizeImage(string filename,     string outputFilename,     int width,     int height,     InterpolationMode mode,     int jpegCompressionMode)

public static Bitmap ResizeImage(Bitmap bmp,     int width,     int height,     InterpolationMode mode)

RoateImage

Rotates an image and writes out the rotated image to a file.

public static bool RoateImage(string filename,     string outputFilename,     RotateFlipType type,     int jpegCompressionMode)

public static Byte[] RoateImage(Byte[] data,     RotateFlipType type)

SaveJpeg

Saves a jpeg BitMap to disk with a jpeg quality setting. Does not dispose the bitmap.

public static bool SaveJpeg(Bitmap bmp,     string outputFileName,     long jpegQuality)

public static bool SaveJpeg(Bitmap bmp,     Stream imageStream,     long jpegQuality)

StripJpgExifData

Opens the image and writes it back out, stripping any Exif data

public static void StripJpgExifData(string imageFile,     int imageQuality)

Encoders

A quick lookup for getting image encoders

Requirements

Namespace: Westwind.Utilities
Assembly: westwind.utilities.dll

© West Wind Technologies, 1996-2020 • Updated: 07/15/20
Comment or report problem with topic