Class DjvuImage

Class DjvuImage

Namespace: Aspose.Imaging.FileFormats.Djvu
Assembly: Aspose.Imaging.dll (25.4.0)

DjVu document class supports graphics file format and facilitates seamless management of scanned documents and books, integrating text, drawings, images, and photos into a single format. Supporting multi-page operations, you can efficiently access unique document identifiers, count pages, set active pages, and retrieve specific document pages. With features for resizing, rotating, dithering, cropping, grayscale transformation, gamma corrections, adjustments, and filters application, this class empowers precise manipulation and enhancement of DjVu images to meet diverse application needs with ease and precision.

[JsonObject(MemberSerialization.OptIn)]
public sealed class DjvuImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImage, INotifyPropertyChanged

Inheritance

objectDisposableObjectDataStreamSupporterImageRasterImageRasterCachedImageRasterCachedMultipageImageDjvuImage

Implements

IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImage, INotifyPropertyChanged

Inherited Members

RasterCachedMultipageImage.AdjustBrightness(int), RasterCachedMultipageImage.AdjustContrast(float), RasterCachedMultipageImage.AdjustGamma(float, float, float), RasterCachedMultipageImage.AdjustGamma(float), RasterCachedMultipageImage.Blend(Point, RasterImage, Rectangle, byte), RasterCachedMultipageImage.BinarizeFixed(byte), RasterCachedMultipageImage.BinarizeBradley(double, int), RasterCachedMultipageImage.BinarizeBradley(double), RasterCachedMultipageImage.BinarizeOtsu(), RasterCachedMultipageImage.Crop(Rectangle), RasterCachedMultipageImage.Crop(int, int, int, int), RasterCachedMultipageImage.Dither(DitheringMethod, int, IColorPalette), RasterCachedMultipageImage.Grayscale(), RasterCachedMultipageImage.NormalizeHistogram(), RasterCachedMultipageImage.Rotate(float, bool, Color), RasterCachedMultipageImage.RotateFlip(RotateFlipType), RasterCachedMultipageImage.RotateFlipAll(RotateFlipType), RasterCachedMultipageImage.Resize(int, int, ResizeType), RasterCachedMultipageImage.Resize(int, int, ImageResizeSettings), RasterCachedMultipageImage.ResizeWidthProportionally(int, ResizeType), RasterCachedMultipageImage.ResizeHeightProportionally(int, ResizeType), RasterCachedMultipageImage.ReplaceColor(int, byte, int), RasterCachedMultipageImage.ReplaceNonTransparentColors(int), RasterCachedMultipageImage.Filter(Rectangle, FilterOptionsBase), RasterCachedMultipageImage.NormalizeAngle(bool, Color), RasterCachedMultipageImage.CacheData(), RasterCachedMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int), RasterCachedMultipageImage.Height, RasterCachedMultipageImage.Width, RasterCachedMultipageImage.BitsPerPixel, RasterCachedMultipageImage.IsCached, RasterCachedMultipageImage.PageCount, RasterCachedMultipageImage.Pages, RasterCachedMultipageImage.HasAlpha, RasterCachedMultipageImage.HasTransparentColor, RasterCachedMultipageImage.ImageOpacity, RasterCachedMultipageImage.BackgroundColor, RasterCachedMultipageImage.XmpData, RasterCachedMultipageImage.PageExportingAction, 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.NormalizeHistogram(), 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.NormalizeHistogram(), 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 DJVU image from a file stream.

string dir = "c:\\temp\\";

                                                                          // Load a DJVU image from a file stream.
                                                                          using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                          {
                                                                              using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
                                                                              {
                                                                                  // Save each page as an individual PNG image.
                                                                                  foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                  {
                                                                                      // Generate a file name based on the page number.
                                                                                      string fileName = string.Format("sample.{0}.png", djvuPage.PageNumber);
                                                                                      djvuPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }
                                                                              }
                                                                          }

Constructors

DjvuImage(Stream)

Start working with DjVu images by initializing a new instance of the Aspose.Imaging.FileFormats.Djvu.DjvuImage class using a Stream parameter. Perfect for developers who want seamless integration of DjVu image processing into their projects.

public DjvuImage(Stream stream)

Parameters

stream Stream

The stream.

Examples

This example shows how to load a DJVU image from a file stream.

string dir = "c:\\temp\\";

                                                                          // Load a DJVU image from a file stream.
                                                                          using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                          {
                                                                              using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
                                                                              {
                                                                                  // Save each page as an individual PNG image.
                                                                                  foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                  {
                                                                                      // Generate a file name based on the page number.
                                                                                      string fileName = string.Format("sample.{0}.png", djvuPage.PageNumber);
                                                                                      djvuPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }
                                                                              }
                                                                          }

Exceptions

DjvuImageException

Stream is empty

DjvuImage(Stream, LoadOptions)

Start working with DjVu images seamlessly with this constructor, which initializes a new Aspose.Imaging.FileFormats.Djvu.DjvuImage class instance using a Stream and LoadOptions parameters. Perfect for developers who want precise control over DjVu image loading options while maintaining simplicity and efficiency.

public DjvuImage(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

The stream to load from.

loadOptions LoadOptions

The load options.

Examples

This example shows how to load a DJVU image from a file stream to stay within the specified memory limit.

string dir = "c:\\temp\\";

                                                                                                                    // Load a DJVU image from a file stream.
                                                                                                                    using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                                                                    {
                                                                                                                        // The max allowed size for all internal buffers is 1MB.
                                                                                                                        Aspose.Imaging.LoadOptions loadOptions = new Aspose.Imaging.LoadOptions();
                                                                                                                        loadOptions.BufferSizeHint = 1 * 1024 * 1024;

                                                                                                                        using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream, loadOptions))
                                                                                                                        {
                                                                                                                            // Save each page as an individual PNG image.
                                                                                                                            foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                                                            {
                                                                                                                                // Generate a file name based on the page number.
                                                                                                                                string fileName = string.Format("sample.{0}.png", djvuPage.PageNumber);
                                                                                                                                djvuPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }

Exceptions

DjvuImageException

Stream is empty

Properties

ActivePage

Navigate through your DjVu document by accessing or setting the currently active page using this property. Seamlessly switch between pages to focus on specific content and enhance your document viewing experience.

public DjvuPage ActivePage { get; set; }

Property Value

DjvuPage

Examples

This example shows how to load a DJVU image from a file stream and print information about the pages.

string dir = "c:\\temp\\";

                                                                                                                // Load a DJVU image from a file stream.
                                                                                                                using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                                                                {
                                                                                                                    using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
                                                                                                                    {
                                                                                                                        System.Console.WriteLine("The total number of pages: {0}", djvuImage.Pages.Length);
                                                                                                                        System.Console.WriteLine("The active page number:    {0}", djvuImage.ActivePage.PageNumber);
                                                                                                                        System.Console.WriteLine("The first page number:     {0}", djvuImage.FirstPage.PageNumber);
                                                                                                                        System.Console.WriteLine("The last page number:      {0}", djvuImage.LastPage.PageNumber);

                                                                                                                        foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                                                        {
                                                                                                                            System.Console.WriteLine("--------------------------------------------------");
                                                                                                                            System.Console.WriteLine("Page number:     {0}", djvuPage.PageNumber);
                                                                                                                            System.Console.WriteLine("Page size:       {0}", djvuPage.Size);
                                                                                                                            System.Console.WriteLine("Page raw format: {0}", djvuPage.RawDataFormat);
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                                //The output may look like this:
                                                                                                                //The total number of pages: 2
                                                                                                                //The active page number:    1
                                                                                                                //The first page number:     1
                                                                                                                //The last page number:      2
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     1
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     2
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1

Exceptions

DjvuImageException

There is no active page selected.

DjvuPages

Quickly retrieve all the pages contained within your DjVu document using this property. Simplify your document processing workflow by easily accessing and managing individual pages within your DjVu files. Improve efficiency and streamline your tasks with convenient page retrieval.

public DjvuPage[] DjvuPages { get; }

Property Value

DjvuPage[]

FileFormat

Obtain the file format information associated with your DjVu image file. Quickly determine the format of your file for seamless integration into your workflow.

public override FileFormat FileFormat { get; }

Property Value

FileFormat

FirstPage

Access the first page of your DjVu document with this property. Quickly retrieve the initial page to begin viewing or processing your document efficiently.

public DjvuPage FirstPage { get; }

Property Value

DjvuPage

Examples

This example shows how to load a DJVU image from a file stream and print information about the pages.

string dir = "c:\\temp\\";

                                                                                                                // Load a DJVU image from a file stream.
                                                                                                                using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                                                                {
                                                                                                                    using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
                                                                                                                    {
                                                                                                                        System.Console.WriteLine("The total number of pages: {0}", djvuImage.Pages.Length);
                                                                                                                        System.Console.WriteLine("The active page number:    {0}", djvuImage.ActivePage.PageNumber);
                                                                                                                        System.Console.WriteLine("The first page number:     {0}", djvuImage.FirstPage.PageNumber);
                                                                                                                        System.Console.WriteLine("The last page number:      {0}", djvuImage.LastPage.PageNumber);

                                                                                                                        foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                                                        {
                                                                                                                            System.Console.WriteLine("--------------------------------------------------");
                                                                                                                            System.Console.WriteLine("Page number:     {0}", djvuPage.PageNumber);
                                                                                                                            System.Console.WriteLine("Page size:       {0}", djvuPage.Size);
                                                                                                                            System.Console.WriteLine("Page raw format: {0}", djvuPage.RawDataFormat);
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                                //The output may look like this:
                                                                                                                //The total number of pages: 2
                                                                                                                //The active page number:    1
                                                                                                                //The first page number:     1
                                                                                                                //The last page number:      2
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     1
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     2
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1

Exceptions

DjvuImageException

The first page can not be found

HasAlpha

Quickly determine whether your DjVu image file contains an alpha channel. Simplify your workflow by checking for the presence of transparency information in your images.

public override bool HasAlpha { get; }

Property Value

bool

Identifier

Gets the unique identifier for the document

public int Identifier { get; }

Property Value

int

LastPage

Retrieve the last page of your DjVu document using this property. Quickly access the final page for viewing or processing purposes with ease.

public DjvuPage LastPage { get; }

Property Value

DjvuPage

Examples

This example shows how to load a DJVU image from a file stream and print information about the pages.

string dir = "c:\\temp\\";

                                                                                                                // Load a DJVU image from a file stream.
                                                                                                                using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                                                                {
                                                                                                                    using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
                                                                                                                    {
                                                                                                                        System.Console.WriteLine("The total number of pages: {0}", djvuImage.Pages.Length);
                                                                                                                        System.Console.WriteLine("The active page number:    {0}", djvuImage.ActivePage.PageNumber);
                                                                                                                        System.Console.WriteLine("The first page number:     {0}", djvuImage.FirstPage.PageNumber);
                                                                                                                        System.Console.WriteLine("The last page number:      {0}", djvuImage.LastPage.PageNumber);

                                                                                                                        foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                                                        {
                                                                                                                            System.Console.WriteLine("--------------------------------------------------");
                                                                                                                            System.Console.WriteLine("Page number:     {0}", djvuPage.PageNumber);
                                                                                                                            System.Console.WriteLine("Page size:       {0}", djvuPage.Size);
                                                                                                                            System.Console.WriteLine("Page raw format: {0}", djvuPage.RawDataFormat);
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                                //The output may look like this:
                                                                                                                //The total number of pages: 2
                                                                                                                //The active page number:    1
                                                                                                                //The first page number:     1
                                                                                                                //The last page number:      2
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     1
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     2
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1

Exceptions

DjvuImageException

The last page can not be found

NextPage

Navigate through your DjVu document by accessing the next page with this convenient property. Quickly move forward in your document viewing or processing tasks.

public DjvuPage NextPage { get; }

Property Value

DjvuPage

Exceptions

DjvuImageException

The next page can not be found

PageCount

Retrieve the total number of pages in your DjVu image collection with this property. Ideal for quickly assessing the extent of your document or book stored in DjVu format. Improve your workflow efficiency with accurate page count information.

public override int PageCount { get; }

Property Value

int

Pages

Access the individual pages of your DjVu image collection with this property. Simplify navigation and manipulation of your document or book stored in DjVu format by accessing each page directly. Improve your workflow efficiency with easy page retrieval.

public override Image[] Pages { get; }

Property Value

Image[]

Examples

This example shows how to load a DJVU image from a file stream.

string dir = "c:\\temp\\";

                                                                          // Load a DJVU image from a file stream.
                                                                          using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                          {
                                                                              using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
                                                                              {
                                                                                  // Save each page as an individual PNG image.
                                                                                  foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                  {
                                                                                      // Generate a file name based on the page number.
                                                                                      string fileName = string.Format("sample.{0}.png", djvuPage.PageNumber);
                                                                                      djvuPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }
                                                                              }
                                                                          }

PreviousPage

Quickly move backward in your DjVu document viewing or processing tasks by accessing the previous page with this convenient property. Efficiently navigate through your document with ease.

public DjvuPage PreviousPage { get; }

Property Value

DjvuPage

Exceptions

DjvuImageException

The previous page can not be found

Methods

AdjustBrightness(int)

Adjust the brightness of an image using a specified parameter, providing control over luminance levels for optimal visual clarity. This method enhances or diminishes the overall brightness of the image, allowing for fine adjustments to achieve desired lighting effects. By modulating brightness, users can optimize image visibility and enhance detail reproduction for improved viewing experience.

public override void AdjustBrightness(int brightness)

Parameters

brightness int

Brightness value.

Examples

The following example performs brightness correction of a DJVU image.

string dir = "c:\\temp\\";

                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                {
                                                                                    Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                    // Set the brightness value. The accepted values of brightness are in the range [-255, 255].
                                                                                    djvuImage.AdjustBrightness(50);
                                                                                    djvuImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                }

AdjustContrast(float)

Enhance Aspose.Imaging.Image contrast to improve visual clarity and highlight details with this method, which adjusts the difference in brightness between light and dark areas. By fine-tuning contrast levels, users can achieve more vivid and impactful images, enhancing overall image quality and maximizing detail visibility. This adjustment helps to bring out subtle nuances in color and texture, resulting in more dynamic and visually appealing images.

public override void AdjustContrast(float contrast)

Parameters

contrast float

Contrast value (in range [-100; 100])

Examples

The following example performs contrast correction of a DJVU image.

string dir = "c:\\temp\\";

                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                              {
                                                                                  Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                  // Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
                                                                                  djvuImage.AdjustContrast(50f);
                                                                                  djvuImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                              }

AdjustGamma(float)

Gamma correction, specifically for the red, green, and blue channels, involves adjusting the brightness of each color component separately. By applying different gamma coefficients to the RGB channels, you can fine-tune the overall brightness and contrast of an image. This technique ensures accurate color representation and improves the visual quality of the image across different display devices.

public override void AdjustGamma(float gamma)

Parameters

gamma float

Gamma for red, green and blue channels coefficient

Examples

The following example performs gamma-correction of a DJVU image.

string dir = "c:\\temp\\";

                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                           {
                                                                               Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                               // Set gamma coefficient for red, green and blue channels.
                                                                               djvuImage.AdjustGamma(2.5f);
                                                                               djvuImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                           }

AdjustGamma(float, float, float)

Gamma correction is applied to an image with customizable parameters for the red, green, and blue channels, allowing precise adjustment of color balance and brightness. This method enhances image quality by fine-tuning color representation, ensuring optimal rendering across different display devices. Adjusting gamma values for individual channels improves color balance and visual appeal.

public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)

Parameters

gammaRed float

Gamma for red channel coefficient

gammaGreen float

Gamma for green channel coefficient

gammaBlue float

Gamma for blue channel coefficient

Examples

The following example performs gamma-correction of a DJVU image applying different coefficients for color components.

string dir = "c:\\temp\\";

                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                {
                                                                                                                                    Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                                    // Set individual gamma coefficients for red, green and blue channels.
                                                                                                                                    djvuImage.AdjustGamma(1.5f, 2.5f, 3.5f);
                                                                                                                                    djvuImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                }

BinarizeBradley(double, int)

Binarization using Bradley’s adaptive thresholding algorithm with integral image thresholding is a method that calculates a local threshold for each pixel based on a local neighborhood. It adapts to variations in illumination across the image, making it suitable for images with uneven lighting conditions. By computing the threshold using integral images, it efficiently handles large neighborhoods, making it applicable to real-time applications. This technique is commonly used in document processing, OCR (Optical Character Recognition), and image segmentation tasks where accurate binarization is essential for subsequent analysis.

public override void BinarizeBradley(double brightnessDifference, int windowSize)

Parameters

brightnessDifference double

The brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.

windowSize int

The size of s x s window of pixels centered around this pixel

Examples

The following example binarizes a DJVU image with Bradley’s adaptive thresholding algorithm with the specified window size. Binarized images contain only 2 colors - black and white.

string dir = "c:\\temp\\";

                                                                                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                                                {
                                                                                                                                                                                                    Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                                                                                                    // Binarize the image with a brightness difference of 5. The brightness is a difference between a pixel and the average of an 10 x 10 window of pixels centered around this pixel.
                                                                                                                                                                                                    djvuImage.BinarizeBradley(5, 10);
                                                                                                                                                                                                    djvuImage.Save(dir + "sample.BinarizeBradley5_10x10.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                                                }

BinarizeFixed(byte)

Binarization with a predefined threshold simplifies complex images into binary representations, where pixels are categorized as either black or white based on their intensity compared to a specified threshold value. This technique is commonly used in image processing to enhance clarity, simplify analysis, and prepare images for further processing steps such as optical character recognition (OCR). By applying a fixed threshold, you can quickly transform grayscale images into binary form, making them easier to interpret and extract meaningful information from.

public override void BinarizeFixed(byte threshold)

Parameters

threshold byte

Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.

Examples

The following example binarizes a DJVU image with the predefined threshold. Binarized images contain only 2 colors - black and white.

string dir = "c:\\temp\\";

                                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                {
                                                                                                                                                    Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                                                    // Binarize the image with a threshold value of 127.
                                                                                                                                                    // If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
                                                                                                                                                    djvuImage.BinarizeFixed(127);
                                                                                                                                                    djvuImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                }

BinarizeOtsu()

Binarization using Otsu thresholding is a technique that automatically calculates an optimal threshold value based on the image’s histogram. It separates the image into foreground and background by minimizing the intra-class variance. Otsu’s method is widely used for segmenting images into binary form, particularly when the distribution of pixel intensities is bimodal or multimodal. This approach is beneficial for tasks such as object detection, image segmentation, and feature extraction, where accurate delineation between foreground and background is crucial.

public override void BinarizeOtsu()

Examples

The following example binarizes a DJVU image with Otsu thresholding. Binarized images contain only 2 colors - black and white.

string dir = "c:\\temp\\";

                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                         {
                                                                                                                                             Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                                             // Binarize the image with Otsu thresholding.
                                                                                                                                             djvuImage.BinarizeOtsu();
                                                                                                                                             djvuImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                         }

CacheData()

Cache the data privately to optimize performance and reduce the need for repeated data retrieval from external sources. This approach also helps conserve resources, particularly in scenarios where data access is frequent or resources are limited.

public override void CacheData()

Examples

The following example shows how to cache all pages of a DJVU image.

string dir = "c:\\temp\\";

                                                                              // Load an image from a DJVU file.
                                                                              using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                              {
                                                                                  // This call caches all the pages so that no additional data loading will be performed from the underlying data stream.
                                                                                  image.CacheData();

                                                                                  // Or you can cache the pages individually.
                                                                                  foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage page in image.Pages)
                                                                                  {
                                                                                      page.CacheData();
                                                                                  }
                                                                              }

Crop(Rectangle)

“Crop” trims your image to focus on specific details or remove unwanted elements, enhancing its composition and visual impact. Whether you’re adjusting photos for social media, creating website banners, or designing print materials, this tool helps you refine your images with precision and clarity.

public override void Crop(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle.

Examples

The following example crops a DJVU image. The cropping area is be specified via Aspose.Imaging.Rectangle.

string dir = "c:\\temp\\";

                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                        // Crop the image. The cropping area is the rectangular central area of the image.
                                                                                                                        Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(djvuImage.Width / 4, djvuImage.Height / 4, djvuImage.Width / 2, djvuImage.Height / 2);
                                                                                                                        djvuImage.Crop(area);

                                                                                                                        // Save the cropped image to PNG
                                                                                                                        djvuImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                    }

Crop(int, int, int, int)

Crop with shifts allows you to precisely adjust the position and dimensions of the cropped area within an image. This feature is invaluable for refining compositions, aligning elements, and emphasizing focal points in your visuals. By incorporating shifts into the cropping process, you can achieve pixel-perfect precision and fine-tune the framing of your images with ease.

public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)

Parameters

leftShift int

The left shift.

rightShift int

The right shift.

topShift int

The top shift.

bottomShift int

The bottom shift.

Dither(DitheringMethod, int, IColorPalette)

The “Dither” function applies a dithering effect to your image, enhancing its visual quality by reducing banding and improving color transitions. Whether you’re working on digital art, photography, or graphic design projects, this feature adds a professional touch to your images, making them appear smoother and more refined.

public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)

Parameters

ditheringMethod DitheringMethod

The dithering method.

bitsCount int

The final bits count for dithering.

customPalette IColorPalette

The custom palette for dithering.

Examples

The following example loads a DJVU image and performs threshold and floyd dithering using different palette depth.

string dir = "c:\\temp\\";

                                                                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                             {
                                                                                                                                 Aspose.Imaging.FileFormats.Djvu.DjvuImage dicomImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                                 // Perform threshold dithering using 4-bit color palette which contains 16 colors.
                                                                                                                                 // The more bits specified the higher quality and the bigger size of the output image.
                                                                                                                                 // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
                                                                                                                                 dicomImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);

                                                                                                                                 dicomImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                             }

                                                                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                             {
                                                                                                                                 Aspose.Imaging.FileFormats.Djvu.DjvuImage dicomImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                                 // Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
                                                                                                                                 // The more bits specified the higher quality and the bigger size of the output image.
                                                                                                                                 // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
                                                                                                                                 dicomImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);

                                                                                                                                 dicomImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                             }

Filter(Rectangle, FilterOptionsBase)

Apply filters to a specified rectangular area within the image to enhance or modify its appearance. By targeting specific regions, this method allows for precise adjustments, such as blurring, sharpening, or applying artistic effects, to achieve desired visual outcomes. Fine-tuning filters on selected areas empowers users to customize image aesthetics, improve clarity, and create artistic effects tailored to their preferences.

public override void Filter(Rectangle rectangle, FilterOptionsBase options)

Parameters

rectangle Rectangle

The rectangle.

options FilterOptionsBase

The options.

Examples

The following example applies various types of filters to a DJVU image.

string dir = "c:\\temp\\";

                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                  {
                                                                                      Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                      // Apply a median filter with a rectangle size of 5 to the entire image.
                                                                                      djvuImage.Filter(djvuImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
                                                                                      djvuImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                  {
                                                                                      Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                      // Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
                                                                                      djvuImage.Filter(djvuImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
                                                                                      djvuImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                  {
                                                                                      Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                      // Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
                                                                                      djvuImage.Filter(djvuImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
                                                                                      djvuImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                  {
                                                                                      Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                      // Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
                                                                                      djvuImage.Filter(djvuImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
                                                                                      djvuImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                  {
                                                                                      Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                      // Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image.
                                                                                      djvuImage.Filter(djvuImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
                                                                                      djvuImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                  {
                                                                                      Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                      // Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
                                                                                      djvuImage.Filter(djvuImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
                                                                                      djvuImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

Grayscale()

Grayscale transformation converts an image to a black-and-white representation, where each pixel’s intensity is represented by a single value ranging from black to white. This process removes color information, resulting in a monochromatic image. Grayscale images are commonly used in applications where color is unnecessary or where simplicity is preferred, such as document scanning, printing, and certain types of image analysis.

public override void Grayscale()

Examples

The following example transforms a colored DJVU image to its grayscale representation. Grayscale images are composed exclusively of shades of gray and carry only intensity information.

string dir = "c:\\temp\\";

                                                                                                                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                                                   {
                                                                                                                                                                                                       Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                                                                                                                                       djvuImage.Grayscale();
                                                                                                                                                                                                       djvuImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                                                   }

LoadDocument(Stream)

Load your DjVu document with this method. Streamline your process by quickly accessing and importing your DjVu files into your application.

public static DjvuImage LoadDocument(Stream stream)

Parameters

stream Stream

The stream.

Returns

DjvuImage

Loaded djvu document

LoadDocument(Stream, LoadOptions)

Import your DjVu document by utilizing this method with stream and loadOptions parameters. Streamline your process by quickly accessing and importing DjVu files into your application, providing flexibility and customization options to meet your needs.

public static DjvuImage LoadDocument(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

The stream.

loadOptions LoadOptions

The load options.

Returns

DjvuImage

Loaded djvu document

ReleaseManagedResources()

Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.

protected override void ReleaseManagedResources()

Resize(int, int, ResizeType)

Resize the image using the Resize method, providing a simple and effective way to adjust the dimensions of your images according to your requirements. This versatile functionality empowers you to easily scale images to your desired size, enhancing their usability across various platforms and applications.

public override void Resize(int newWidth, int newHeight, ResizeType resizeType)

Parameters

newWidth int

The new width.

newHeight int

The new height.

resizeType ResizeType

The resize type.

Examples

This example loads a DJVU image and resizes it using various resizing methods.

string dir = "c:\\temp\\";

                                                                                         using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                         {
                                                                                             // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                             image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                             // Save to PNG with default options.
                                                                                             image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                         }

                                                                                         using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                         {
                                                                                             // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                             image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                             // Save to PNG with default options.
                                                                                             image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                         }

                                                                                         using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                         {
                                                                                             // Scale up by 2 times using Bilinear resampling.
                                                                                             image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                             // Save to PNG with default options.
                                                                                             image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                         }

                                                                                         using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                         {
                                                                                             // Scale down by 2 times using Bilinear resampling.
                                                                                             image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                             // Save to PNG with default options.
                                                                                             image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                         }

Resize(int, int, ImageResizeSettings)

Resize the image to the specified width and height while applying additional settings as needed. This method enables users to adjust the dimensions of the image while maintaining desired attributes such as aspect ratio, image quality, and compression settings. By providing flexibility in resizing options, users can tailor the image to fit specific requirements and optimize its appearance for various applications and platforms.

public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)

Parameters

newWidth int

The new width.

newHeight int

The new height.

settings ImageResizeSettings

The resize settings.

Examples

This example loads a DJVU image and resizes it using various resizing settings.

string dir = "c:\\temp\\";

                                                                                          Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();

                                                                                          // The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
                                                                                          resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;

                                                                                          // The small rectangular filter
                                                                                          resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;

                                                                                          // The number of colors in the palette.
                                                                                          resizeSettings.EntriesCount = 256;

                                                                                          // The color quantization is not used
                                                                                          resizeSettings.ColorQuantizationMethod = ColorQuantizationMethod.None;

                                                                                          // The euclidian method
                                                                                          resizeSettings.ColorCompareMethod = ColorCompareMethod.Euclidian;

                                                                                          using (Aspose.Imaging.Image image = (Aspose.Imaging.Image)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                          {
                                                                                              Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

                                                                                              // Scale down by 2 times using adaptive resampling.
                                                                                              djvuImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);

                                                                                              // Save to PNG
                                                                                              djvuImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                          }

ResizeHeightProportionally(int, ResizeType)

The ResizeHeightProportionally method allows you to adjust the height of your image while preserving its aspect ratio. This ensures that your image maintains its proportions, preventing distortion and preserving its visual integrity. Whether you’re optimizing images for web pages, mobile apps, or print media, this method ensures that your images look their best across different platforms and devices.

public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)

Parameters

newHeight int

The new height.

resizeType ResizeType

Type of the resize.

Examples

This example loads a DJVU image and resizes it proportionally using various resizing methods. Only the height is specified, the width is calculated automatically.

string dir = "c:\\temp\\";

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                                 image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                                 image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale up by 2 times using Bilinear resampling.
                                                                                                                                                                                 image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale down by 2 times using Bilinear resampling.
                                                                                                                                                                                 image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

ResizeWidthProportionally(int, ResizeType)

The ResizeWidthProportionally method offers a convenient solution to adjust the width of your image while maintaining its aspect ratio. By proportionally resizing the width, you can ensure that your images remain visually appealing and consistent across different devices and screen sizes, enhancing their versatility and usability in various contexts.

public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)

Parameters

newWidth int

The new width.

resizeType ResizeType

Type of the resize.

Examples

This example loads a DJVU image and resizes it proportionally using various resizing methods. Only the width is specified, the height is calculated automatically.

string dir = "c:\\temp\\";

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                                 image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                                 image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale up by 2 times using Bilinear resampling.
                                                                                                                                                                                 image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

                                                                                                                                                                             using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                                             {
                                                                                                                                                                                 // Scale down by 2 times using Bilinear resampling.
                                                                                                                                                                                 image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                                                                                                                 // Save to PNG with the default options.
                                                                                                                                                                                 image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                             }

Rotate(float, bool, Color)

Rotate the image around its center with the Rotate method of the RasterCachedMultipageImage class. This convenient feature allows you to easily adjust the orientation of images while maintaining their center position, enhancing your image manipulation capabilities.

public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)

Parameters

angle float

The rotate angle in degrees. Positive values will rotate clockwise.

resizeProportionally bool

if set to true you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.

backgroundColor Color

Color of the background.

RotateFlip(RotateFlipType)

The RotateFlip method offers versatile manipulation options for your image, allowing you to rotate, flip, or perform both operations on the active frame independently. Whether you’re editing photos, creating graphics, or enhancing digital art, this method provides precise control over the orientation and composition of your images, ensuring they meet your creative vision with ease and efficiency.

public override void RotateFlip(RotateFlipType rotateFlipType)

Parameters

rotateFlipType RotateFlipType

The rotate flip type.

Examples

This example loads a DJVU image, rotates it by 90 degrees clockwise and optionally flips the image horizontally and(or) vertically.

string dir = "c:\\temp\\";

                                                                                                                                              Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
                                                                                                                                                  Aspose.Imaging.RotateFlipType.Rotate90FlipX,
                                                                                                                                                  Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
                                                                                                                                                  Aspose.Imaging.RotateFlipType.Rotate90FlipY,
                                                                                                                                              };

                                                                                                                                              foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
                                                                                                                                              {
                                                                                                                                                  // Rotate, flip and save to the output file.
                                                                                                                                                  using (Aspose.Imaging.FileFormats.Djvu.DjvuImage image = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)Aspose.Imaging.Image.Load(dir + "sample.djvu"))
                                                                                                                                                  {
                                                                                                                                                      image.RotateFlip(rotateFlipType);
                                                                                                                                                      image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                  }
                                                                                                                                              }

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.

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler