Class Jpeg2000Image
Namespace: Aspose.Imaging.FileFormats.Jpeg2000
Assembly: Aspose.Imaging.dll (25.2.0)
Efficiently manipulate JPEG2000 (JP2) image files with our API, supporting a range of bits per pixel depths and seamless processing of XMP metadata containing essential image information. With capabilities for lossless compression, ensure optimal image quality while maintaining file integrity, empowering you to tailor JP2 images to your exact specifications with ease.
[JsonObject(MemberSerialization.OptIn)]
public sealed class Jpeg2000Image : RasterCachedImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← Jpeg2000Image
Implements
IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata
Inherited Members
RasterCachedImage.CacheData(), RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte), RasterCachedImage.Resize(int, int, ResizeType), RasterCachedImage.Resize(int, int, ImageResizeSettings), RasterCachedImage.RotateFlip(RotateFlipType), RasterCachedImage.Rotate(float, bool, Color), RasterCachedImage.Crop(Rectangle), RasterCachedImage.Dither(DitheringMethod, int, IColorPalette), RasterCachedImage.Grayscale(), RasterCachedImage.BinarizeFixed(byte), RasterCachedImage.BinarizeOtsu(), RasterCachedImage.BinarizeBradley(double, int), RasterCachedImage.BinarizeBradley(double), RasterCachedImage.AdjustBrightness(int), RasterCachedImage.AdjustContrast(float), RasterCachedImage.AdjustGamma(float, float, float), RasterCachedImage.AdjustGamma(float), RasterCachedImage.IsCached, RasterImage.RemoveMetadata(), RasterImage.Save(Stream, ImageOptionsBase, Rectangle), RasterImage.GetModifyDate(bool), RasterImage.Dither(DitheringMethod, int), RasterImage.Dither(DitheringMethod, int, IColorPalette), RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader), RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings), RasterImage.GetDefaultArgb32Pixels(Rectangle), RasterImage.GetDefaultRawData(Rectangle, RawDataSettings), RasterImage.GetArgb32Pixel(int, int), RasterImage.GetPixel(int, int), RasterImage.SetArgb32Pixel(int, int, int), RasterImage.SetPixel(int, int, Color), RasterImage.ReadScanLine(int), RasterImage.ReadArgb32ScanLine(int), RasterImage.WriteScanLine(int, Color[]), RasterImage.WriteArgb32ScanLine(int, int[]), RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader), RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader), RasterImage.LoadArgb32Pixels(Rectangle), RasterImage.LoadArgb64Pixels(Rectangle), RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader), RasterImage.LoadPixels(Rectangle), RasterImage.LoadCmykPixels(Rectangle), RasterImage.LoadCmyk32Pixels(Rectangle), RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader), RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader), RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings), RasterImage.SaveArgb32Pixels(Rectangle, int[]), RasterImage.SavePixels(Rectangle, Color[]), RasterImage.SaveCmykPixels(Rectangle, CmykColor[]), RasterImage.SaveCmyk32Pixels(Rectangle, int[]), RasterImage.SetResolution(double, double), RasterImage.SetPalette(IColorPalette, bool), RasterImage.Resize(int, int, ImageResizeSettings), RasterImage.Rotate(float, bool, Color), RasterImage.Rotate(float), RasterImage.BinarizeFixed(byte), RasterImage.BinarizeOtsu(), RasterImage.BinarizeBradley(double), RasterImage.BinarizeBradley(double, int), RasterImage.Blend(Point, RasterImage, Rectangle, byte), RasterImage.Blend(Point, RasterImage, byte), RasterImage.Grayscale(), RasterImage.AdjustBrightness(int), RasterImage.AdjustContrast(float), RasterImage.AdjustGamma(float, float, float), RasterImage.AdjustGamma(float), RasterImage.GetSkewAngle(), RasterImage.NormalizeAngle(), RasterImage.NormalizeAngle(bool, Color), RasterImage.Filter(Rectangle, FilterOptionsBase), RasterImage.ReplaceColor(Color, byte, Color), RasterImage.ReplaceColor(int, byte, int), RasterImage.ReplaceNonTransparentColors(Color), RasterImage.ReplaceNonTransparentColors(int), RasterImage.ToBitmap(), RasterImage.PremultiplyComponents, RasterImage.UseRawData, RasterImage.UpdateXmpData, RasterImage.XmpData, RasterImage.RawIndexedColorConverter, RasterImage.RawCustomColorConverter, RasterImage.RawFallbackIndex, RasterImage.RawDataSettings, RasterImage.UsePalette, RasterImage.RawDataFormat, RasterImage.RawLineSize, RasterImage.IsRawDataAvailable, RasterImage.HorizontalResolution, RasterImage.VerticalResolution, RasterImage.HasTransparentColor, RasterImage.HasAlpha, RasterImage.TransparentColor, RasterImage.ImageOpacity, Image.CanLoad(string), Image.CanLoad(string, LoadOptions), Image.CanLoad(Stream), Image.CanLoad(Stream, LoadOptions), Image.Create(ImageOptionsBase, int, int), Image.Create(Image[]), Image.Create(MultipageCreateOptions), Image.Create(string[], bool), Image.Create(string[]), Image.Create(Image[], bool), Image.GetFileFormat(string), Image.GetFileFormat(Stream), Image.GetFittingRectangle(Rectangle, int, int), Image.GetFittingRectangle(Rectangle, int[], int, int), Image.Load(string, LoadOptions), Image.Load(string), Image.Load(Stream, LoadOptions), Image.Load(Stream), Image.GetProportionalWidth(int, int, int), Image.GetProportionalHeight(int, int, int), Image.RemoveMetadata(), Image.CanSave(ImageOptionsBase), Image.Resize(int, int), Image.Resize(int, int, ResizeType), Image.Resize(int, int, ImageResizeSettings), Image.GetDefaultOptions(object[]), Image.GetOriginalOptions(), Image.ResizeWidthProportionally(int), Image.ResizeHeightProportionally(int), Image.ResizeWidthProportionally(int, ResizeType), Image.ResizeHeightProportionally(int, ResizeType), Image.ResizeWidthProportionally(int, ImageResizeSettings), Image.ResizeHeightProportionally(int, ImageResizeSettings), Image.RotateFlip(RotateFlipType), Image.Rotate(float), Image.Crop(Rectangle), Image.Crop(int, int, int, int), Image.Save(), Image.Save(string), Image.Save(string, ImageOptionsBase), Image.Save(string, ImageOptionsBase, Rectangle), Image.Save(Stream, ImageOptionsBase), Image.Save(Stream, ImageOptionsBase, Rectangle), Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int), Image.SetPalette(IColorPalette, bool), Image.BitsPerPixel, Image.Bounds, Image.Container, Image.Height, Image.Palette, Image.UsePalette, Image.Size, Image.Width, Image.InterruptMonitor, Image.BufferSizeHint, Image.AutoAdjustPalette, Image.HasBackgroundColor, Image.FileFormat, Image.BackgroundColor, DataStreamSupporter.CacheData(), DataStreamSupporter.Save(), DataStreamSupporter.Save(Stream), DataStreamSupporter.Save(string), DataStreamSupporter.Save(string, bool), DataStreamSupporter.DataStreamContainer, DataStreamSupporter.IsCached, DisposableObject.Dispose(), DisposableObject.Disposed, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
This example shows how to load a JPEG2000 image from a file and save it to PNG.```csharp [C#]
string dir = "c:\\temp\\";
// Load a JPEG2000 image.
using (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image(dir + "sample.jp2"))
{
// Save to PNG
jpeg2000Image.Save(dir + "sample.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
## Constructors
### <a id="Aspose_Imaging_FileFormats_Jpeg2000_Jpeg2000Image__ctor_System_String_"></a> Jpeg2000Image\(string\)
Start working with the Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image class by initializing a new
instance with the path to the image you want to load. This constructor enables easy
access to JPEG2000 images, simplifying the process of loading and handling image
files. By providing the file path, you can quickly begin processing and
manipulating JPEG2000 images in your application.
```csharp
public Jpeg2000Image(string path)
Parameters
path
string
The path to load image from and initialize pixel and palette data with.
Examples
This example shows how to load a JPEG2000 image from a file and save it to PNG.```csharp [C#]
string dir = "c:\\temp\\";
// Load a JPEG2000 image.
using (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image(dir + "sample.jp2"))
{
// Save to PNG
jpeg2000Image.Save(dir + "sample.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
### <a id="Aspose_Imaging_FileFormats_Jpeg2000_Jpeg2000Image__ctor_System_String_System_Int32_"></a> Jpeg2000Image\(string, int\)
Get started easily with the Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image class by creating a new
instance with both the file path and the desired bits per pixel parameter. This
constructor allows for fine-tuning the image loading process, ensuring
compatibility with various image formats and quality settings. With this
flexibility, you can efficiently manage and manipulate JPEG2000 images according to
your specific requirements.
```csharp
public Jpeg2000Image(string path, int bitsPerPixel)
Parameters
path
string
The path to load image from and initialize pixel and palette data with
bitsPerPixel
int
The bits per pixel.
Jpeg2000Image(Stream)
Easily initialize a new instance of the Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image class by providing a stream object. This constructor simplifies the process of loading JPEG2000 images directly from streams, offering flexibility and convenience for handling image data from various sources.
public Jpeg2000Image(Stream stream)
Parameters
stream
Stream
The stream to load image from and initialize pixel and palette data with.
Examples
This example shows how to load a JPEG2000 image from a file stream and save it to PNG.```csharp [C#]
string dir = "c:\\temp\\";
// Load a JPEG2000 image from stream.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.jp2"))
using (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image(stream))
{
// Save to PNG
jpeg2000Image.Save(dir + "sample.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
### <a id="Aspose_Imaging_FileFormats_Jpeg2000_Jpeg2000Image__ctor_System_IO_Stream_System_Int32_"></a> Jpeg2000Image\(Stream, int\)
Initialize a new instance of the Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image class with a stream to
load the image, along with bits per pixel parameters. This constructor offers
flexibility by allowing you to specify both the image data source and the desired
bits per pixel, providing finer control over the image loading process.
```csharp
public Jpeg2000Image(Stream stream, int bitsPerPixel)
Parameters
stream
Stream
The stream to load image from and initialize pixel and palette data with.
bitsPerPixel
int
The bits per pixel.
Jpeg2000Image(int, int)
Create a new instance of the Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image class, specifying the width and height parameters. This constructor allows you to initialize a JPEG2000 image with specific dimensions, which is useful for scenarios where you need to create an image of a certain size programmatically.
public Jpeg2000Image(int width, int height)
Parameters
width
int
The image width
height
int
The image height
Examples
This example shows how to create a JPEG2000 image and save it to a file.```csharp [C#]
string dir = "c:\\temp\\";
// Create a JPEG2000 image of 100x100 px.
using (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image(100, 100))
{
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpeg2000Image);
// Fill the entire image in red.
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
graphics.FillRectangle(brush, jpeg2000Image.Bounds);
// Save to a file
jpeg2000Image.Save(dir + "sample.output.jp2", new Aspose.Imaging.ImageOptions.Jpeg2000Options());
}
### <a id="Aspose_Imaging_FileFormats_Jpeg2000_Jpeg2000Image__ctor_System_Int32_System_Int32_Aspose_Imaging_ImageOptions_Jpeg2000Options_"></a> Jpeg2000Image\(int, int, Jpeg2000Options\)
Instantiate a new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image object, providing the width, height,
and image options parameters. This constructor allows for the creation of JPEG2000
images with specific dimensions and additional options, offering flexibility in
image generation.
```csharp
public Jpeg2000Image(int width, int height, Jpeg2000Options options)
Parameters
width
int
The image width
height
int
The image height
options
Jpeg2000Options
The options.
Examples
This example shows how to create a PNG image and save it to JPEG2000 with the desired options.```csharp [C#]
string dir = "c:\\temp\\";
// Create a PNG image of 100x100 px.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
{
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);
// Fill the entire image in red.
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
graphics.FillRectangle(brush, pngImage.Bounds);
Aspose.Imaging.ImageOptions.Jpeg2000Options saveOptions = new Aspose.Imaging.ImageOptions.Jpeg2000Options();
// Use the irreversible Discrete Wavelet Transform 9-7
saveOptions.Irreversible = true;
// JP2 is the "container" format for JPEG 2000 codestreams.
// J2K is raw compressed data, without a wrapper.
saveOptions.Codec = Imaging.FileFormats.Jpeg2000.Jpeg2000Codec.J2K;
// Save to a file
pngImage.Save(dir + "output.j2k", saveOptions);
}
This example shows how to create a JPEG2000 image with the desired options and save it to a file.```csharp
[C#]
string dir = "c:\\temp\\";
Aspose.Imaging.ImageOptions.Jpeg2000Options createOptions = new Aspose.Imaging.ImageOptions.Jpeg2000Options();
// Use the irreversible Discrete Wavelet Transform 9-7
createOptions.Irreversible = true;
// JP2 is the "container" format for JPEG 2000 codestreams.
// J2K is raw compressed data, without a wrapper.
createOptions.Codec = Imaging.FileFormats.Jpeg2000.Jpeg2000Codec.J2K;
// Create a JPEG2000 image of 100x100 px.
using (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image(100, 100, createOptions))
{
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpeg2000Image);
// Fill the entire image in red.
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
graphics.FillRectangle(brush, jpeg2000Image.Bounds);
// Save to a file
jpeg2000Image.Save(dir + "sample.output.j2k");
}
Jpeg2000Image(int, int, int)
Create a new instance of the Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image class with parameters for width, height, and bits count. This constructor allows for the creation of JPEG2000 images with specific dimensions and bit depths, providing flexibility for various imaging needs.
public Jpeg2000Image(int width, int height, int bitsCount)
Parameters
width
int
The image width
height
int
The image height
bitsCount
int
The bits count.
Jpeg2000Image(RasterImage)
Instantiate a new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image class with a raster image. This constructor facilitates the creation of a JPEG2000 image from an existing raster image, offering seamless integration and conversion between different image formats.
public Jpeg2000Image(RasterImage image)
Parameters
image
RasterImage
The image.
Examples
This example shows how to create a JPEG2000 image with from another raster image.```csharp [C#]
string dir = "c:\\temp\\";
// Create a PNG image of 100x100 px.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
{
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);
// Fill the entire image in red.
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
graphics.FillRectangle(brush, pngImage.Bounds);
// Create a JPEG2000 image based on the PNG image.
using (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = new Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image(pngImage))
{
// Save to a file
jpeg2000Image.Save(dir + "output.jp2", new Aspose.Imaging.ImageOptions.Jpeg2000Options());
}
}
### <a id="Aspose_Imaging_FileFormats_Jpeg2000_Jpeg2000Image__ctor_Aspose_Imaging_RasterImage_System_Int32_"></a> Jpeg2000Image\(RasterImage, int\)
Initialize a fresh Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image instance with a raster image and
bits per pixel parameters. This constructor enables precise control over the
quality and size of the resulting JPEG2000 image, making it ideal for scenarios
where customization is crucial.
```csharp
public Jpeg2000Image(RasterImage rasterImage, int bitsPerPixel)
Parameters
rasterImage
RasterImage
The image to initialize pixel and palette data with.
bitsPerPixel
int
The bits per pixel.
Properties
BitsPerPixel
This property returns the depth of the image, measured in bits per pixel (bpp). It indicates the amount of color information stored in each pixel of the image. Understanding the image depth is crucial for determining the color fidelity and quality of the image. With this information, users can gauge the level of detail and richness of colors present in the image.
public override int BitsPerPixel { get; }
Property Value
Codec
This property retrieves the JPEG2000 codec associated with the image. The JPEG2000 codec is responsible for encoding and decoding the image data in the JPEG2000 format, providing efficient compression while maintaining high image quality. Accessing this codec can be useful for performing advanced image processing operations or optimizing image compression settings tailored to specific requirements.
public Jpeg2000Codec Codec { get; }
Property Value
Comments
This property allows for retrieving or updating the comments associated with the image. Comments provide additional information about the image content, such as annotations, descriptions, or metadata. Modifying these comments can be useful for organizing and categorizing images, as well as conveying important details to viewers or users.
public string[] Comments { get; set; }
Property Value
string[]
FileFormat
Retrieve the format of the image file. This property provides information about the file format of the image. Utilize this property to determine the format of the image file programmatically, facilitating appropriate handling and processing based on the file’s format.
public override FileFormat FileFormat { get; }
Property Value
Height
This property retrieves the height of the image in pixels. It serves as essential information for understanding the image’s vertical dimensions, aiding in various image manipulation tasks like resizing, cropping, and rendering. Accessing this property allows users to ascertain the image’s vertical size, enabling precise layout and display in applications.
public override int Height { get; }
Property Value
HorizontalResolution
This property allows you to retrieve or modify the horizontal resolution of the Aspose.Imaging.RasterImage, measured in pixels per inch (PPI). Adjusting this resolution can impact the size and quality of the image when printed or displayed. By setting the horizontal resolution, users can optimize the image for specific output devices or applications, ensuring the best possible visual results.
public override double HorizontalResolution { get; set; }
Property Value
Examples
The following example shows how to set horizontal/vertical resolution of a JPEG2000 image.```csharp [C#]
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jp2"))
{
Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image)image;
// Get horizontal and vertical resolution of the Jpeg2000Image.
double horizontalResolution = jpeg2000Image.HorizontalResolution;
double verticalResolution = jpeg2000Image.VerticalResolution;
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);
if (horizontalResolution != 96.0 || verticalResolution != 96.0)
{
// Use the SetResolution method for updating both resolution values in a single call.
System.Console.WriteLine("Set resolution values to 96 dpi");
jpeg2000Image.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", jpeg2000Image.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", jpeg2000Image.VerticalResolution);
}
}
#### Remarks
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
### <a id="Aspose_Imaging_FileFormats_Jpeg2000_Jpeg2000Image_RawDataFormat"></a> RawDataFormat
This property retrieves the raw data format of the image. It provides information
about how the pixel data is stored in memory. Use this property to understand the
underlying data format of the image, which can be crucial for various image
processing operations like color conversion, compression, or decompression.
```csharp
public override PixelDataFormat RawDataFormat { get; }
Property Value
RawLineSize
This property retrieves the size of a single line of raw image data in bytes. It indicates the amount of memory occupied by a single row of pixels in the image’s raw data format. Understanding the raw line size is essential for tasks such as memory allocation, data manipulation, and image processing algorithms that operate on individual image lines.
public override int RawLineSize { get; }
Property Value
VerticalResolution
This property provides access to the vertical resolution of the Aspose.Imaging.RasterImage, measured in pixels per inch (PPI). Modifying this resolution can affect the quality and size of the image when printed or displayed. By adjusting the vertical resolution, users can optimize the image for different output devices or applications, ensuring optimal visual rendering.
public override double VerticalResolution { get; set; }
Property Value
Examples
The following example shows how to set horizontal/vertical resolution of a JPEG2000 image.```csharp [C#]
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jp2"))
{
Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image jpeg2000Image = (Aspose.Imaging.FileFormats.Jpeg2000.Jpeg2000Image)image;
// Get horizontal and vertical resolution of the Jpeg2000Image.
double horizontalResolution = jpeg2000Image.HorizontalResolution;
double verticalResolution = jpeg2000Image.VerticalResolution;
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);
if (horizontalResolution != 96.0 || verticalResolution != 96.0)
{
// Use the SetResolution method for updating both resolution values in a single call.
System.Console.WriteLine("Set resolution values to 96 dpi");
jpeg2000Image.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", jpeg2000Image.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", jpeg2000Image.VerticalResolution);
}
}
#### Remarks
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
### <a id="Aspose_Imaging_FileFormats_Jpeg2000_Jpeg2000Image_Width"></a> Width
This property returns the width of the image in pixels. It provides a fundamental
piece of information about the image's dimensions, crucial for various image
processing tasks, including resizing, cropping, and rendering.
```csharp
public override int Width { get; }
Property Value
XmpData
Retrieve or modify the XMP metadata associated with the image. This property grants access to the Extensible Metadata Platform (XMP) information embedded within the image file, allowing for manipulation or extraction of metadata attributes such as author details, copyright information, and descriptive tags. Utilizing this property empowers you to manage and leverage metadata embedded within the image, enhancing interoperability and metadata-driven workflows in your image processing tasks.
public override XmpPacketWrapper XmpData { get; set; }
Property Value
Methods
GetOriginalOptions()
Retrieve the image options based on the original file settings. This method is beneficial for maintaining the bit-depth and other parameters of the original image, ensuring consistency and preserving the integrity of the image data. Accessing these options facilitates seamless handling and processing of the image while retaining its original characteristics. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the Aspose.Imaging.DataStreamSupporter.Save(System.String) 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 Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) method as the second parameter.
public override ImageOptionsBase GetOriginalOptions()
Returns
The options based on the original file settings.
SaveData(Stream)
Saves the data.
protected override void SaveData(Stream stream)
Parameters
stream
Stream
The stream to save data to.
UpdateDimensions(int, int)
Updates the image dimensions.
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
The new image width.
newHeight
int
The new image height.