JpegOptions Class
The jpeg file format create options.
Inheritance Hierarchy
SystemObject
  Aspose.ImagingDisposableObject
    Aspose.ImagingImageOptionsBase
      Aspose.Imaging.ImageOptionsJpegOptions

Namespace: Aspose.Imaging.ImageOptions
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
Syntax
public class JpegOptions : ImageOptionsBase

The JpegOptions type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleJpegOptions
Initializes a new instance of the JpegOptions class.
Public methodJpegOptions(JpegOptions)
Initializes a new instance of the JpegOptions class.
Properties
  NameDescription
Public propertyCode exampleBitsPerChannel
Gets or sets bits per channel for lossless jpeg image. Now we support from 2 to 8 bits per channel.
Public propertyCode exampleBufferSizeHint
Gets or sets the buffer size hint which is defined max allowed size for all internal buffers.
(Inherited from ImageOptionsBase.)
Public propertyCode exampleCmykColorProfile
The destination CMYK color profile for CMYK jpeg images. Use for saving images. Must be in pair with RGBColorProfile for correct color conversion.
Public propertyCode exampleColorType
Gets or sets the color type for jpeg image.
Public propertyComment
Gets or sets the jpeg file comment.
Public propertyCode exampleCompressionType
Gets or sets the compression type.
Public propertyDefaultMemoryAllocationLimit Obsolete.
Gets or sets the default memory allocation limit.
Public propertyDisposed
Gets a value indicating whether this instance is disposed.
(Inherited from DisposableObject.)
Public propertyExifData
Get or set exif data container
Public propertyFullFrame
Gets or sets a value indicating whether [full frame].
(Inherited from ImageOptionsBase.)
Public propertyHorizontalSampling
Gets or sets the horizontal subsamplings for each component.
Public propertyJfif
Gets or sets the jfif.
Public propertyJpegLsAllowedLossyError
Gets or sets the JPEG-LS difference bound for near-lossless coding (NEAR parameter from the JPEG-LS specification).
Public propertyJpegLsInterleaveMode
Gets or sets the JPEG-LS interleave mode.
Public propertyJpegLsPreset
Gets or sets the JPEG-LS preset parameters.
Public propertyMultiPageOptions
The multipage options
(Inherited from ImageOptionsBase.)
Public propertyCode examplePalette
Gets or sets the color palette.
(Inherited from ImageOptionsBase.)
Public propertyPreblendAlphaIfPresent
Gets or sets a value indicating whether red, green and blue components should be mixed with a background color, if alpha channel is present.
Public propertyCode exampleProgressEventHandler
Gets or sets the progress event handler.
(Inherited from ImageOptionsBase.)
Public propertyCode exampleQuality
Gets or sets image quality.
Public propertyRdOptSettings
Gets or sets the RD optimizer settings.
Public propertyCode exampleResolutionSettings
Gets or sets the resolution settings.
(Inherited from ImageOptionsBase.)
Public propertyCode exampleResolutionUnit
Gets or sets the resolution unit.
Public propertyCode exampleRgbColorProfile
The destination RGB color profile for CMYK jpeg images. Use for saving images. Must be in pair with CMYKColorProfile for correct color conversion.
Public propertySampleRoundingMode
Gets or sets the sample rounding mode to fit an 8-bit value to an n-bit value. BitsPerChannel
Public propertyScaledQuality
The scaled quality.
Public propertySource
Gets or sets the source to create image in.
(Inherited from ImageOptionsBase.)
Public propertyVectorRasterizationOptions
Gets or sets the vector rasterization options.
(Inherited from ImageOptionsBase.)
Public propertyVerticalSampling
Gets or sets the vertical subsamplings for each component.
Public propertyXmpData
Gets or sets the XMP metadata container.
(Overrides ImageOptionsBaseXmpData.)
Methods
  NameDescription
Public methodClone
Clones this instance.
(Inherited from ImageOptionsBase.)
Public methodCode exampleDispose
Disposes the current instance.
(Inherited from DisposableObject.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize (Inherited from DisposableObject.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodReleaseManagedResources
Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.
(Inherited from ImageOptionsBase.)
Protected methodReleaseUnmanagedResources
Releases the unmanaged resources. Make sure no managed resources are released here, since they may have been already released.
(Inherited from DisposableObject.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodVerifyNotDisposed
Verifies that the current instance is not disposed.
(Inherited from DisposableObject.)
Fields
  NameDescription
Protected fieldxmpData
XMP metadata of image.
(Inherited from ImageOptionsBase.)
Examples
This example demonstrates the use of System.IO.Stream to Create a new Image file (a JPEG type)
[C#]

//Creates an instance of JpegOptions and set its various properties
Aspose.Imaging.ImageOptions.JpegOptions jpegOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

//Create an instance of System.IO.Stream
System.IO.Stream stream = new System.IO.FileStream(@"C:\temp\sample.jpeg", System.IO.FileMode.Create);

//Define the source property for the instance of JpegOptions
//Second boolean parameter determins if the Stream is disposed once get out of scope
jpegOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream, true);

//Creates an instance of Image and call Create method with JpegOptions as parameter to initialize the Image object   
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(jpegOptions, 500, 500))
{
    //do some image processing
}
Examples
This example demonstrates the use of different classes from SaveOptions Namespace for export purposes. An image of type Gif is loaded into an instance of Image and then exported out to several formats.
[C#]

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

//Load an existing image (of type Gif) in an instance of Image class
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
    //Export to BMP file format using the default options
    image.Save(dir + "output.bmp", new Aspose.Imaging.ImageOptions.BmpOptions());

    //Export to JPEG file format using the default options
    image.Save(dir + "output.jpg", new Aspose.Imaging.ImageOptions.JpegOptions());

    //Export to PNG file format using the default options
    image.Save(dir + "output.png", new Aspose.Imaging.ImageOptions.PngOptions());

    //Export to TIFF file format using the default options
    image.Save(dir + "output.tif", new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default));
}
Examples
The following example shows how to convert a multipage vector image to JPEG format in general way without referencing to a particular image type.
[C#]

string dir = "C:\\aspose.imaging\\net\\misc\\ImagingReleaseQATester\\Tests\\testdata\\2548";
string inputFilePath = System.IO.Path.Combine(dir, "Multipage.cdr");
string outputFilePath = System.IO.Path.Combine(dir, "Multipage.cdr.jpeg");

Aspose.Imaging.ImageOptionsBase exportOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFilePath))
{
    exportOptions.MultiPageOptions = null;

    // Export only first two pages. In fact, only one page will be rasterized because JPEG is not a multi-page format.
    Aspose.Imaging.IMultipageImage multipageImage = image as Aspose.Imaging.IMultipageImage;
    if (multipageImage != null && (multipageImage.Pages != null && multipageImage.PageCount > 2))
    {
        exportOptions.MultiPageOptions = new Aspose.Imaging.ImageOptions.MultiPageOptions(new Aspose.Imaging.IntRange(0, 2));
    }

    if (image is Aspose.Imaging.VectorImage)
    {
        exportOptions.VectorRasterizationOptions = (Aspose.Imaging.ImageOptions.VectorRasterizationOptions)image.GetDefaultOptions(new object[] { Aspose.Imaging.Color.White, image.Width, image.Height });
        exportOptions.VectorRasterizationOptions.TextRenderingHint = Aspose.Imaging.TextRenderingHint.SingleBitPerPixel;
        exportOptions.VectorRasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.None;
    }

    image.Save(outputFilePath, exportOptions);
}
See Also