Class ImageSaveOptions

Class ImageSaveOptions

Namespace: Aspose.Note.Saving
Assembly: Aspose.Note.dll (25.6.0)

Allows to specify additional options when rendering document pages to images.

public class ImageSaveOptions : SaveOptions
{
    private bool embedImages;
    private ImageFormat imageFormat;
    public ImageSaveOptions()
    {
        this.embedImages = true;
        this.imageFormat = ImageFormat.Png;
    }
    public void SetEmbedImages(bool value)
    {
        this.embedImages = value;
    }
    public bool GetEmbedImages()
    {
        return this.embedImages;
    }
    public ImageFormat GetImageFormat()
    {
        return this.imageFormat;
    }
    public void SetImageFormat(ImageFormat format)
    {
        this.imageFormat = format;
    }
}

Inheritance

object SaveOptions ImageSaveOptions

Inherited Members

SaveOptions.SaveFormat , SaveOptions.FontsSubsystem , SaveOptions.PageIndex , SaveOptions.PageCount , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Shows how to save a document as image in Jpeg format using SaveFormat.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToJpegImageUsingSaveFormat_out.jpg";
   oneFile.Save(dataDir, SaveFormat.Jpeg);

Shows how to set a image quality when saving document as image in JPEG format.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
string dataDirWithOutputImagePath = dataDir + @"\SetOutputImageResolution_out.jpg";
doc.Save(dataDirWithOutputImagePath, new ImageSaveOptions { Quality = 100 });

Shows how to save a document as image in Bmp format using ImageSaveOptions.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   string dataDirWithOutputPath = dataDir + "SaveToBmpImageUsingImageSaveOptions_out.bmp";
   oneFile.Save(dataDirWithOutputPath, new ImageSaveOptions { SaveFormat = SaveFormat.Bmp });

Shows how to set a image resolution when saving document as image.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   string dataDirWithOutputImagePath = dataDir + "SetOutputImageResolution_out.jpg";
   doc.Save(dataDirWithOutputImagePath, new ImageSaveOptions { Resolution = 220, SaveFormat = SaveFormat.Jpeg });

Shows how to save a document as grayscale image.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += @"\SaveAsGrayscaleImage_out.png";
oneFile.Save(dataDir, new ImageSaveOptions()
{
    SaveFormat = SaveFormat.Png,
    ColorMode = ColorMode.GrayScale
});

Shows how to save a document as image in Tiff format using PackBits compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
      Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
      var dst = Path.Combine(dataDir, "SaveToTiffUsingPackBitsCompression.tiff");
      oneFile.Save(dst,
                   new ImageSaveOptions(SaveFormat.Tiff)
                   {
                       TiffCompression = TiffCompression.PackBits
                   });

Shows how to save notebook as image with specified options.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   var notebookSaveOptions = new NotebookImageSaveOptions { SaveFormat = SaveFormat.Png };
   var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
   documentSaveOptions.Resolution = 400;
   dataDir += "ConvertToImageWithOptions_out.png";
   notebook.Save(dataDir, notebookSaveOptions);

Shows how to save a document as image in Tiff format using Jpeg compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
   oneFile.Save(dst,
      new ImageSaveOptions(SaveFormat.Tiff)
      {
         TiffCompression = TiffCompression.Jpeg,
         Quality = 93
      });

Shows how to save flattened notebook as image.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch öffnen.onetoc2");
   var notebookSaveOptions = new NotebookImageSaveOptions(SaveFormat.Png)
   {
      DocumentSaveOptions = new DocumentSaveOptions()
      {
         Resolution = 400
      }
   };
   notebookSaveOptions.Flatten = true;
   dataDir += "ConvertToImageAsFlattenedNotebook_out.png";
   notebook.Save(dataDir, notebookSaveOptions);

Shows how to save a document as image in Tiff format using CCITT Group 3 fax compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
   oneFile.Save(dst, new ImageSaveOptions()
   {
      SaveFormat = SaveFormat.Tiff,
      ColorMode = ColorMode.BlackAndWhite,
      TiffCompression = TiffCompression.Ccitt3
   });

Shows how to save a document in png format.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.Png)
   {
      PageIndex = 1
   };
   string dataDirWithOutputPath = dataDir + "ConvertSpecificPageToImage_out.png";
   oneFile.Save(dataDirWithOutputPath, opts);

Shows how to save a document as binary image using Otsu’s method.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBinaryImageUsingOtsuMethod_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
   {
      ColorMode = ColorMode.BlackAndWhite,
      BinarizationOptions = new ImageBinarizationOptions()
      {
         BinarizationMethod = BinarizationMethod.Otsu
      }
   });

Shows how to save a document as binary image using fixed threshold.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBinaryImageUsingFixedThreshold_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
   {
      ColorMode = ColorMode.BlackAndWhite,
      BinarizationOptions = new ImageBinarizationOptions()
      {
         BinarizationMethod = BinarizationMethod.FixedThreshold,
         BinarizationThreshold = 123
      }
   });

Constructors

ImageSaveOptions(SaveFormat)

Initializes a new instance of the Aspose.Note.Saving.ImageSaveOptions class.

public ImageSaveOptions(SaveFormat format)
   {
       this.Format = format;
   }

Parameters

format SaveFormat

The format in which the document is saved.

Properties

BinarizationOptions

Gets or sets options for image’s binarization.

public ImageBinarizationOptions BinarizationOptions
   {
      get;
      set;
   }

Property Value

ImageBinarizationOptions

Examples

Shows how to save a document as binary image using Otsu’s method.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBinaryImageUsingOtsuMethod_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions()
   {
      SaveFormat = SaveFormat.Png,
      ColorMode = ColorMode.BlackAndWhite,
      BinarizationOptions = new ImageBinarizationOptions()
      {
         BinarizationMethod = BinarizationMethod.Otsu,
      }
   });

Shows how to save a document as binary image using fixed threshold.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBinaryImageUsingFixedThreshold_out.png";
   oneFile.Save(
      dataDir,
      new ImageSaveOptions(SaveFormat.Png)
      {
         ColorMode = ColorMode.BlackAndWhite,
         BinarizationOptions = new ImageBinarizationOptions()
         {
            BinarizationMethod = BinarizationMethod.FixedThreshold,
            BinarizationThreshold = 123
         }
      });

ColorMode

Gets or sets Aspose.Note.Saving.ImageSaveOptions.ColorMode for the output image.

public ColorMode ColorMode
    {
        get;
        private set;
    }

Property Value

ColorMode

Examples

Shows how to save a document as grayscale image.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveAsGrayscaleImage_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
   {
      ColorMode = ColorMode.GrayScale
   });

Shows how to save a document as image in Tiff format using CCITT Group 3 fax compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
   oneFile.Save(dst,
      new ImageSaveOptions(SaveFormat.Tiff)
      {
         ColorMode = ColorMode.BlackAndWhite,
         TiffCompression = TiffCompression.Ccitt3
      });

Shows how to save a document as binary image using Otsu’s method.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   string dataDirWithOutputPath = dataDir + "SaveToBinaryImageUsingOtsuMethod_out.png";
   oneFile.Save(dataDirWithOutputPath, new ImageSaveOptions(SaveFormat.Png)
   {
      ColorMode = ColorMode.BlackAndWhite,
      BinarizationOptions = new ImageBinarizationOptions()
      {
         BinarizationMethod = BinarizationMethod.Otsu
      }
   });

Shows how to save a document as binary image using fixed threshold.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(dataDir + "Aspose.one");
   dataDir += "SaveToBinaryImageUsingFixedThreshold_out.png";
   oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
   {
      ColorMode = ColorMode.BlackAndWhite,
      BinarizationOptions = new ImageBinarizationOptions()
      {
         BinarizationMethod = BinarizationMethod.FixedThreshold,
         BinarizationThreshold = 123
      }
   });

Quality

Gets or sets a value determining the quality of saved image.This value is passed to codec as System.Drawing.Imaging.Encoder.Quality parameter.

public int Quality
    {
        get;
        private set;
    }

Property Value

int

Examples

Shows how to set a image quality when saving document as image in JPEG format.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   dataDir += "SetOutputImageResolution_out.jpg";
   var saveOptions = new ImageSaveOptions { Quality = 100, SaveFormat = SaveFormat.Jpeg };
   doc.Save(dataDir, saveOptions);

Shows how to save a document as image in Tiff format using Jpeg compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
   oneFile.Save(dst, new ImageSaveOptions
   {
      SaveFormat = SaveFormat.Tiff,
      TiffCompression = TiffCompression.Jpeg,
      Quality = 93
   });

Remarks

The range of useful values for the quality category is from 0 to 100.The lower the number specified, the higher the compression and therefore the lower the quality of the image.Zero would give you the lowest quality image and 100 the highest.The default value is 90.

Resolution

Gets or sets the resolution for the generated images, in dots per inch.

public float Resolution
    {
        get
        {
        }
        set
        {
        }
    }

Property Value

float

Examples

Shows how to set a image resolution when saving document as image.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document doc = new Document(dataDir + "Aspose.one");
   string dataDirWithOutputFile = dataDir + "SetOutputImageResolution_out.jpg";
   doc.Save(dataDirWithOutputFile, new ImageSaveOptions { SaveFormat = SaveFormat.Jpeg, Resolution = 220 });

Shows how to save notebook as image with specified options.

var dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch öffnen.onetoc2");
   var notebookSaveOptions = new NotebookImageSaveOptions { SaveFormat = SaveFormat.Png };
   var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
   documentSaveOptions.Resolution = 400;
   dataDir += "ConvertToImageWithOptions_out.png";
   notebook.Save(dataDir, notebookSaveOptions);

Shows how to save flattened notebook as image.

string dataDir = RunExamples.GetDataDir_NoteBook();
    var notebook = new Notebook(dataDir + "Notizbuch öffnen.onetoc2");
    var notebookSaveOptions = new NotebookImageSaveOptions(SaveFormat.Png);
    var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
    documentSaveOptions.Resolution = 400;
    notebookSaveOptions.Flatten = true;
    dataDir += "ConvertToImageAsFlattenedNotebook_out.png";
    notebook.Save(dataDir, notebookSaveOptions);

Remarks

The default value is 96.

TiffCompression

Gets or sets the type of compression to use when saving generated images to the TIFF format.

public TiffCompression TiffCompression
   {
      get;
      set;
   }

Property Value

TiffCompression

Examples

Shows how to save a document as image in Tiff format using PackBits compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
      Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
      var dst = Path.Combine(dataDir, "SaveToTiffUsingPackBitsCompression.tiff");
      oneFile.Save(dst,
                   new ImageSaveOptions(SaveFormat.Tiff)
                   {
                       TiffCompression = TiffCompression.PackBits
                   });

Shows how to save a document as image in Tiff format using Jpeg compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
   oneFile.Save(dst, new ImageSaveOptions()
   {
      SaveFormat = SaveFormat.Tiff,
      TiffCompression = TiffCompression.Jpeg,
      Quality = 93
   });

Shows how to save a document as image in Tiff format using CCITT Group 3 fax compression.

string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
   Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
   var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
   oneFile.Save(dst, new ImageSaveOptions()
   {
      SaveFormat = SaveFormat.Tiff,
      ColorMode = ColorMode.BlackAndWhite,
      TiffCompression = TiffCompression.Ccitt3
   });
 English