Class JpegImage
Contents
[
Hide
]JpegImage class
Efficiently manipulate JPEG raster images with our API, offering support for various color profiles such as RGB and CMYK, customizable bits per pixel resolution, and processing of EXIF, JFIF, and XMP metadata containers. Enjoy automated rotation based on orientation data and choose from different compression levels, including lossless JPEG, to achieve optimal image quality and file size balance for your projects.
public sealed class JpegImage : RasterCachedImage, IHasJpegExifData
Constructors
Name | Description |
---|---|
JpegImage(RasterImage) | Initialize a new instance of the JpegImage class with a raster image parameter. This constructor provides a convenient way to create JPEG images directly from raster images, streamlining the workflow for working with JPEG images in your applications. |
JpegImage(Stream) | Initialize a JPEG image object with the JpegImage class using a stream parameter. This constructor simplifies the process of working with JPEG images, offering a straightforward approach for integrating them into your projects effortlessly. |
JpegImage(string) | The JpegImage class initiates effortlessly by invoking its constructor with the specified path parameter. This constructor enables seamless creation of JPEG images, ensuring swift integration into your projects with ease. |
JpegImage(int, int) | Create a new instance of the JpegImage class with the specified width and height parameters. This constructor allows you to create JPEG images with custom dimensions, giving you flexibility in managing image sizes in your application. |
JpegImage(JpegOptions, int, int) | Initialize a new JpegImage object with the provided JPEG options. This constructor empowers you to tailor various settings for the JPEG image, such as compression level, quality, and additional parameters, granting precise control over the resulting image format. |
Properties
Name | Description |
---|---|
AutoAdjustPalette { get; set; } | Gets or sets a value indicating whether automatic adjust palette. |
virtual BackgroundColor { get; set; } | Gets or sets a value for the background color. |
override BitsPerPixel { get; } | Retrieve the pixel depth of the image effortlessly with this property, offering insights into the richness of color or grayscale representation. Whether it’s a vibrant photograph or a monochrome illustration, this property provides crucial information about the image’s visual complexity. |
Bounds { get; } | Gets the image bounds. |
BufferSizeHint { get; set; } | Gets or sets the buffer size hint which is defined max allowed size for all internal buffers. |
CmykColorProfile { get; set; } | The CMYK color profile associated with CMYK and YCCK JPEG images ensures precise color conversion and fidelity. It works in conjunction with the RGBColorProfile to guarantee accurate color representation across various devices and applications. This pairing is crucial for maintaining consistency in color rendering and achieving optimal image quality. |
Comment { get; set; } | Manage JPEG file comments with this property, allowing you to add or retrieve descriptive annotations associated with the image. Whether it’s tagging images with metadata or appending additional context, this property offers flexibility in organizing and categorizing your JPEG files. |
Container { get; } | Gets the Image container. |
DataStreamContainer { get; } | Gets the object’s data stream. |
DestinationCmykColorProfile { get; set; } | The CMYK color profile is vital for the accurate color conversion of CMYK and YCCK JPEG images during the saving process. It works in tandem with the RGBColorProfile to ensure correct color representation, maintaining consistency and quality across different devices and software. This synchronization is crucial for achieving accurate and reliable color rendering in the final saved images. |
DestinationRgbColorProfile { get; set; } | The RGBColorProfile is essential for the accurate color conversion of CMYK and YCCK JPEG images during the saving process. When paired with the CMYKColorProfile, it ensures that the colors are rendered correctly and maintains consistency across different devices and applications. This combination is crucial for preserving the intended color representation and achieving high-quality image output. |
Disposed { get; } | Gets a value indicating whether this instance is disposed. |
ExifData { get; set; } | Manage EXIF data with this property, allowing you to add or retrieve metadata associated with the image. Whether it’s extracting information about the camera settings or modifying existing metadata, this property offers flexibility in managing the EXIF data container. |
override FileFormat { get; } | Retrieve the format of the image effortlessly with this property. It provides valuable insight into the file format, aiding in seamless integration and compatibility checks across various platforms and applications. |
virtual HasAlpha { get; } | Gets a value indicating whether this instance has alpha. |
virtual HasBackgroundColor { get; set; } | Gets or sets a value indicating whether image has background color. |
virtual HasTransparentColor { get; set; } | Gets a value indicating whether image has transparent color. |
override Height { get; } | Retrieve the height of the image effortlessly with this property. It provides quick access to the vertical dimension of the image, allowing you to efficiently determine its size and aspect ratio without the need for complex calculations or additional methods. |
override HorizontalResolution { get; set; } | This property grants you access to the horizontal resolution of the RasterImage , measured in pixels per inch. By setting or retrieving this value, you can precisely control the resolution of the image, ensuring it meets your specific requirements for quality and clarity. |
IgnoreEmbeddedColorProfile { get; set; } | Retrieves or modifies the flag denoting whether the embedded color profile is disregarded. By setting this flag, users can specify whether the default color profile should be used instead of the embedded one. This option ensures greater control over color management, facilitating adjustments for consistency and compatibility across various platforms and applications. |
virtual ImageOpacity { get; } | Gets opacity of this image. |
InterruptMonitor { get; set; } | Gets or sets the interrupt monitor. |
override IsCached { get; } | Gets a value indicating whether image data is cached currently. |
IsRawDataAvailable { get; } | Gets a value indicating whether raw data loading is available. |
Jfif { get; set; } | This property allows you to access or modify the JFIF (JPEG File Interchange Format) data associated with the JPEG image. JFIF is a standard format for exchanging JPEG-compressed images between computers and other devices. By getting or setting this property, you can interact with the JFIF data, which may include information such as the image’s resolution, aspect ratio, and thumbnail. |
JpegOptions { get; } | Gain access to the JPEG options employed during the creation or loading of this JpegImage instance with ease. This property offers valuable details about the specific settings utilized, empowering users to understand and replicate image processing workflows effectively. Whether it’s compression levels, quality settings, or other parameters, this property provides essential insights for seamless image manipulation. |
Palette { get; set; } | Gets or sets the color palette. The color palette is not used when pixels are represented directly. |
virtual PremultiplyComponents { get; set; } | Gets or sets a value indicating whether the image components must be premultiplied. |
RawCustomColorConverter { get; set; } | Gets or sets the custom color converter |
override RawDataFormat { get; } | This property retrieves the raw data format of the image, which indicates how the image data is structured and encoded. Understanding the raw data format is essential for processing or manipulating the image data effectively. It provides insights into the underlying representation of the image, such as whether it’s compressed, encoded in a specific color space, or stored in a particular file format. Accessing this property allows you to gain valuable information about the image’s data structure, enabling you to perform various operations or optimizations tailored to its specific format. |
RawDataSettings { get; } | Gets the current raw data settings. Note when using these settings the data loads without conversion. |
RawFallbackIndex { get; set; } | Gets or sets the fallback index to use when palette index is out of bounds |
RawIndexedColorConverter { get; set; } | Gets or sets the indexed color converter |
virtual RawLineSize { get; } | Gets the raw line size in bytes. |
RgbColorProfile { get; set; } | The RGB color profile for CMYK and YCCK JPEG images ensures accurate color conversion and representation. It must be paired with the CMYKColorProfile to maintain consistency and fidelity in color rendering. This pairing is essential for applications that require precise color management and reproduction of images, ensuring that the RGB data is properly interpreted and displayed. |
Size { get; } | Gets the image size. |
virtual TransparentColor { get; set; } | Gets the image transparent color. |
virtual UpdateXmpData { get; set; } | Gets or sets a value indicating whether to update the XMP metadata. |
override UsePalette { get; } | Gets a value indicating whether the image palette is used. |
virtual UseRawData { get; set; } | Gets or sets a value indicating whether to use raw data loading when the raw data loading is available. |
override VerticalResolution { get; set; } | This property manages the vertical resolution, expressed in pixels per inch, for the associated RasterImage . Adjusting this resolution impacts the size and quality of the image when printed or displayed at a fixed physical size. By setting this property, you control how densely the image’s pixels are packed vertically, affecting its overall sharpness and clarity. |
override Width { get; } | This property retrieves the width of the image, expressed in pixels. It provides essential information about the image’s dimensions, enabling accurate rendering, manipulation, or display of the image data. |
override XmpData { get; set; } | Gets or sets XMP metadata, enabling seamless integration of descriptive information into the image file. Whether you’re extracting existing XMP metadata or updating it with new information, this property simplifies the management of extended metadata, ensuring compatibility with various applications and workflows. |
Methods
Name | Description |
---|---|
override AdjustBrightness(int) | Adjust of a brightness for image. |
override AdjustContrast(float) | Image contrasting |
override AdjustGamma(float) | Gamma-correction of an image. |
override AdjustGamma(float, float, float) | Gamma-correction of an image. |
AutoRotate() | Automatically rotates the image based on orientation data extracted from Exif metadata. This method ensures that images are displayed in the correct orientation, enhancing user experience and eliminating the need for manual adjustments. By analyzing Exif information, the image is rotated accordingly, providing a seamless viewing experience across different platforms and devices. This automated rotation process simplifies image handling and improves overall usability, especially when dealing with large batches of images with varying orientations. |
override BinarizeBradley(double) | Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding |
override BinarizeBradley(double, int) | Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding |
override BinarizeFixed(byte) | Binarization of an image with predefined threshold |
override BinarizeOtsu() | Binarization of an image with Otsu thresholding |
Blend(Point, RasterImage, byte) | Blends this image instance with the overlay image. |
override Blend(Point, RasterImage, Rectangle, byte) | Blends this image instance with the overlay image. |
override CacheData() | Caches the data and ensures no additional data loading will be performed from the underlying DataStreamContainer . |
CanSave(ImageOptionsBase) | Determines whether image can be saved to the specified file format represented by the passed save options. |
override Crop(Rectangle) | Cropping the image. |
virtual Crop(int, int, int, int) | Crop image with shifts. |
Dispose() | Disposes the current instance. |
Dither(DitheringMethod, int) | Performs dithering on the current image. |
override Dither(DitheringMethod, int, IColorPalette) | Performs dithering on the current image. |
virtual Filter(Rectangle, FilterOptionsBase) | Filters the specified rectangle. |
GetArgb32Pixel(int, int) | Gets an image 32-bit ARGB pixel. |
GetDefaultArgb32Pixels(Rectangle) | Gets the default 32-bit ARGB pixels array. |
virtual GetDefaultOptions(object[]) | Gets the default options. |
GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) | Gets the default pixels array using partial pixel loader. |
GetDefaultRawData(Rectangle, RawDataSettings) | Gets the default raw data array. |
GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) | Gets the default raw data array using partial pixel loader. |
override GetModifyDate(bool) | Retrieves the date and time when the resource image underwent its latest modification. This method provides valuable metadata, enabling users to track and manage updates to the image file effectively. By accessing this information, users can ensure the integrity and currency of their image assets, facilitating informed decision-making regarding image usage and maintenance. |
virtual GetOriginalOptions() | Gets the options based on the original file settings. This can be helpful to keep bit-depth and other parameters of the original image unchanged. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the Save method, the output PNG image with 8-bit per pixel will be produced. To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them to the Save method as the second parameter. |
GetPixel(int, int) | Gets an image pixel. |
virtual GetSerializedStream(ImageOptionsBase, Rectangle, out int) | Converts to aps. |
GetSkewAngle() | Gets the skew angle. This method is applicable to scanned text documents, to determine the skew angle when scanning. |
override Grayscale() | Transformation of an image to its grayscale representation |
LoadArgb32Pixels(Rectangle) | Loads 32-bit ARGB pixels. |
LoadArgb64Pixels(Rectangle) | Loads 64-bit ARGB pixels. |
LoadCmyk32Pixels(Rectangle) | Loads pixels in CMYK format. |
LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) | Loads 32-bit ARGB pixels partially by packs. |
LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) | Loads 64-bit ARGB pixels partially by packs. |
LoadPartialPixels(Rectangle, IPartialPixelLoader) | Loads pixels partially by packs. |
LoadPixels(Rectangle) | Loads pixels. |
LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) | Loads raw data. |
LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) | Loads raw data. |
NormalizeAngle() | Normalizes the angle. This method is applicable to scanned text documents to get rid of the skewed scan. This method uses GetSkewAngle and Rotate methods. |
virtual NormalizeAngle(bool, Color) | Normalizes the angle. This method is applicable to scanned text documents to get rid of the skewed scan. This method uses GetSkewAngle and Rotate methods. |
ReadArgb32ScanLine(int) | Reads the whole scan line by the specified scan line index. |
ReadScanLine(int) | Reads the whole scan line by the specified scan line index. |
override RemoveMetadata() | Removes this image instance metadata by setting this XmpData and ExifData values to null . |
ReplaceColor(Color, byte, Color) | Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges. |
virtual ReplaceColor(int, byte, int) | Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges. |
ReplaceNonTransparentColors(Color) | Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges. Note: if you use it on images without transparency, all colors will be replaced with a single one. |
virtual ReplaceNonTransparentColors(int) | Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges. Note: if you use it on images without transparency, all colors will be replaced with a single one. |
Resize(int, int) | Resizes the image. The default NearestNeighbourResample is used. |
override Resize(int, int, ImageResizeSettings) | Resizes the image. |
override Resize(int, int, ResizeType) | Resizes the image. |
ResizeHeightProportionally(int) | Resizes the height proportionally. The default NearestNeighbourResample is used. |
virtual ResizeHeightProportionally(int, ImageResizeSettings) | Resizes the height proportionally. |
virtual ResizeHeightProportionally(int, ResizeType) | Resizes the height proportionally. |
ResizeWidthProportionally(int) | Resizes the width proportionally. The default NearestNeighbourResample is used. |
virtual ResizeWidthProportionally(int, ImageResizeSettings) | Resizes the width proportionally. |
virtual ResizeWidthProportionally(int, ResizeType) | Resizes the width proportionally. |
virtual Rotate(float) | Rotate image around the center. |
override Rotate(float, bool, Color) | Rotate image around the center. |
override RotateFlip(RotateFlipType) | Rotates, flips, or rotates and flips the image. |
Save() | Saves the image data to the underlying stream. |
Save(Stream) | Saves the object’s data to the specified stream. |
override Save(string) | Saves the image to the specified file location. |
Save(Stream, ImageOptionsBase) | Saves the image’s data to the specified stream in the specified file format according to save options. |
virtual Save(string, bool) | Saves the object’s data to the specified file location. |
virtual Save(string, ImageOptionsBase) | Saves the object’s data to the specified file location in the specified file format according to save options. |
override Save(Stream, ImageOptionsBase, Rectangle) | Saves the image’s data to the specified stream in the specified file format according to save options. |
virtual Save(string, ImageOptionsBase, Rectangle) | Saves the object’s data to the specified file location in the specified file format according to save options. |
SaveArgb32Pixels(Rectangle, int[]) | Saves the 32-bit ARGB pixels. |
SaveCmyk32Pixels(Rectangle, int[]) | Saves the pixels. |
SavePixels(Rectangle, Color[]) | Saves the pixels. |
SaveRawData(byte[], int, Rectangle, RawDataSettings) | Saves the raw data. |
SetArgb32Pixel(int, int, int) | Sets an image 32-bit ARGB pixel for the specified position. |
override SetPalette(IColorPalette, bool) | Sets the image palette. |
SetPixel(int, int, Color) | Sets an image pixel for the specified position. |
override SetResolution(double, double) | Establishes the resolution for the specified RasterImage , ensuring accurate scaling and printing capabilities. This method empowers users to tailor the image resolution to suit their specific requirements, whether for digital display or physical reproduction. By setting the resolution, users can optimize image quality and ensure compatibility with various output devices and mediums, enhancing the overall visual experience and usability of the image. |
virtual ToBitmap() | Converts raster image to the bitmap. This method is not supported in versions from .Net7.0 and higher |
WriteArgb32ScanLine(int, int[]) | Writes the whole scan line to the specified scan line index. |
WriteScanLine(int, Color[]) | Writes the whole scan line to the specified scan line index. |
Examples
Access camera manufacturer maker notes in Jpeg image.
[C#]
using (var image = (JpegImage)Image.Load("Sample.jpg"))
{
foreach (var makerNote in image.ExifData.MakerNotes)
{
Console.WriteLine("Name = {0}, Value = {1}", makerNote.Name, makerNote.Value);
}
}
The example shows how to load a JpegImage from a file.
[C#]
string dir = "c:\\temp\\";
// Load a JPEG image from a file.
using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(dir + "sample.jpg"))
{
// Do some image processing.
// Save to another JPEG file.
jpegImage.Save(dir + "sample.output.jpg");
}
See Also
- class RasterCachedImage
- interface IHasJpegExifData
- namespace Aspose.Imaging.FileFormats.Jpeg
- assembly Aspose.Imaging