Class JpegOptions

Class JpegOptions

nazivni prostor: Aspose.Imaging.ImageOptions Sastav: Aspose.Imaging.dll (25.4.0)

Stvaranje visokokvalitetnih JPEG slika bez napora s našim API-om, pružajući prilagodljive slikerazine kompresije za optimizaciju veličine skladištenja bez ugrožavanja kvalitete slike.Koristi od podrške za različite vrste kompresije, u blizini bez gubitka kodiranja,RGB i CMYK boja profili, kao i EXIF, JFIF podatke slike, i XMPKontejnerima, osiguravajući sveobuhvatne i prilagodljive opcije za vaše potrebe za stvaranjem slike.

[JsonObject(MemberSerialization.OptIn)]
public class JpegOptions : ImageOptionsBase, IDisposable, ICloneable, IHasXmpData, IHasJpegExifData, IHasExifData, IHasMetadata

Inheritance

object DisposableObject ImageOptionsBase JpegOptions

Implements

IDisposable , ICloneable , IHasXmpData , IHasJpegExifData , IHasExifData , IHasMetadata

naslijeđeni članovi

ImageOptionsBase.Clone() , ImageOptionsBase.ReleaseManagedResources() , ImageOptionsBase.KeepMetadata , ImageOptionsBase.XmpData , ImageOptionsBase.Source , ImageOptionsBase.Palette , ImageOptionsBase.ResolutionSettings , ImageOptionsBase.VectorRasterizationOptions , ImageOptionsBase.BufferSizeHint , ImageOptionsBase.MultiPageOptions , ImageOptionsBase.FullFrame , ImageOptionsBase.ProgressEventHandler , DisposableObject.Dispose() , DisposableObject.ReleaseManagedResources() , DisposableObject.ReleaseUnmanagedResources() , DisposableObject.VerifyNotDisposed() , DisposableObject.Disposed , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Ovaj primjer pokazuje korištenje System.IO.Stream za stvaranje novog datoteke slike (tip JPEG)

//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
                                                                                                         }

Ovaj primjer pokazuje korištenje različitih razreda iz SaveOptions Namespace za izvozne svrhe. slika tipa Gif se preuzima u primjerak Slika, a zatim se izvozi u nekoliko formata.

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));
                                                                                                                                                                                                                    }

Sljedeći primjer pokazuje kako pretvoriti multipage vektor sliku u JPEG format općenito bez upućivanja na određeni tip slike.

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);
                                                                                                                                                            }

Constructors

JpegOptions()

Inicijalizira novu primjenu Aspose.Imaging.ImageOptions.JpegOption razreda.

[JsonConstructor]
public JpegOptions()

Examples

Sljedeći primjer preuzima BMP sliku i čuva je u JPEG-u pomoću različitih opcija spašavanja.

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

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

Sljedeći primjer pokazuje kako stvoriti JPEG sliku određene veličine s određenim parametrima.

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

                                                                                                                    // Create a JPEG image of 100x100 px.
                                                                                                                    // Use additional options to specify the desired image parameters.
                                                                                                                    Aspose.Imaging.ImageOptions.JpegOptions createOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                                    // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
                                                                                                                    createOptions.BitsPerChannel = 8;

                                                                                                                    // Set the progressive type of compression.
                                                                                                                    createOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                                    // Set the image quality. It is a value between 1 and 100.
                                                                                                                    createOptions.Quality = 100;

                                                                                                                    // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                                    createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                                    createOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                                    // This is a standard option for JPEG images.
                                                                                                                    // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
                                                                                                                    createOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.YCbCr;

                                                                                                                    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(createOptions, 100, 100))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpegImage);

                                                                                                                        Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                            new Aspose.Imaging.Point(jpegImage.Width, jpegImage.Height),
                                                                                                                            Aspose.Imaging.Color.Yellow,
                                                                                                                            Aspose.Imaging.Color.Blue);

                                                                                                                        // Fill the image with a grayscale gradient
                                                                                                                        graphics.FillRectangle(gradientBrush, jpegImage.Bounds);

                                                                                                                        // Save to a file.
                                                                                                                        jpegImage.Save(dir + "output.explicitoptions.jpg");
                                                                                                                    }

JpegOptions(JpegOptions)

Inicijalizira novu primjenu Aspose.Imaging.ImageOptions.JpegOption razreda.

public JpegOptions(JpegOptions jpegOptions)

Parameters

jpegOptions JpegOptions

Opcije za JPEG.

Properties

BitsPerChannel

Dobivaju ili postavljaju bitove po kanalu za bez gubitka jpeg slika. sada podržavamo od 2 do 8 bitova po kanalu.

public byte BitsPerChannel { get; set; }

Vrijednost nekretnina

byte

Examples

Sljedeći primjer preuzima BMP sliku i čuva je u JPEG-u pomoću različitih opcija spašavanja.

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

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

Sljedeći primjer pokazuje kako stvoriti JPEG sliku određene veličine s određenim parametrima.

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

                                                                                                                    // Create a JPEG image of 100x100 px.
                                                                                                                    // Use additional options to specify the desired image parameters.
                                                                                                                    Aspose.Imaging.ImageOptions.JpegOptions createOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                                    // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
                                                                                                                    createOptions.BitsPerChannel = 8;

                                                                                                                    // Set the progressive type of compression.
                                                                                                                    createOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                                    // Set the image quality. It is a value between 1 and 100.
                                                                                                                    createOptions.Quality = 100;

                                                                                                                    // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                                    createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                                    createOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                                    // This is a standard option for JPEG images.
                                                                                                                    // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
                                                                                                                    createOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.YCbCr;

                                                                                                                    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(createOptions, 100, 100))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpegImage);

                                                                                                                        Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                            new Aspose.Imaging.Point(jpegImage.Width, jpegImage.Height),
                                                                                                                            Aspose.Imaging.Color.Yellow,
                                                                                                                            Aspose.Imaging.Color.Blue);

                                                                                                                        // Fill the image with a grayscale gradient
                                                                                                                        graphics.FillRectangle(gradientBrush, jpegImage.Bounds);

                                                                                                                        // Save to a file.
                                                                                                                        jpegImage.Save(dir + "output.explicitoptions.jpg");
                                                                                                                    }

CmykColorProfile

Cilj CMYK boja profil za CMYK jpeg slike. koristi za spašavanje slika. mora biti u paru s RGBColorProfile za ispravnu konverziju boje.

public StreamSource CmykColorProfile { get; set; }

Vrijednost nekretnina

StreamSource

Examples

Sljedeći primjer preuzima PNG i spašava ga na CMYK JPEG pomoću prilagođenog ICC profila. Tada preuzimaju CMYK JPG i sačuvaju ga nazad na RNG. Konverzija boja od RGB do CMYN i od CMYL do RGB obavlja se koristeći prilagojene IP profile.

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

                                                                                                                                                                                                                                                // Load PNG and save it to CMYK JPEG
                                                                                                                                                                                                                                                using (Aspose.Imaging.FileFormats.Png.PngImage image = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Load(dir + "sample.png"))
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                    using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
                                                                                                                                                                                                                                                    using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                        Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
                                                                                                                                                                                                                                                        saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Cmyk;

                                                                                                                                                                                                                                                        // Use custom ICC profiles
                                                                                                                                                                                                                                                        saveOptions.RgbColorProfile = new Aspose.Imaging.Sources.StreamSource(rgbProfileStream);
                                                                                                                                                                                                                                                        saveOptions.CmykColorProfile = new Aspose.Imaging.Sources.StreamSource(cmykProfileStream);

                                                                                                                                                                                                                                                        image.Save(dir + "output.cmyk.jpg", saveOptions);
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                // Load CMYK JPEG and save it to PNG
                                                                                                                                                                                                                                                using (Aspose.Imaging.FileFormats.Jpeg.JpegImage image = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)Image.Load(dir + "output.cmyk.jpg"))
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                    using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
                                                                                                                                                                                                                                                    using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                        // Use custom ICC profiles
                                                                                                                                                                                                                                                        image.RgbColorProfile = new Aspose.Imaging.Sources.StreamSource(rgbProfileStream);
                                                                                                                                                                                                                                                        image.CmykColorProfile = new Aspose.Imaging.Sources.StreamSource(cmykProfileStream);

                                                                                                                                                                                                                                                        Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                                                                                                                        image.Save(dir + "output.rgb.png", saveOptions);
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                }

ColorType

Pronađite ili postavite tip boje za jpeg sliku.

public JpegCompressionColorMode ColorType { get; set; }

Vrijednost nekretnina

JpegCompressionColorMode

Examples

Sljedeći primjer preuzima BMP sliku i čuva je u JPEG-u pomoću različitih opcija spašavanja.

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

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

Sljedeći primjer preuzima PNG i spašava ga na CMYK JPEG pomoću prilagođenog ICC profila. Tada preuzimaju CMYK JPG i sačuvaju ga nazad na RNG. Konverzija boja od RGB do CMYN i od CMYL do RGB obavlja se koristeći prilagojene IP profile.

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

                                                                                                                                                                                                                                                // Load PNG and save it to CMYK JPEG
                                                                                                                                                                                                                                                using (Aspose.Imaging.FileFormats.Png.PngImage image = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Load(dir + "sample.png"))
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                    using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
                                                                                                                                                                                                                                                    using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                        Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
                                                                                                                                                                                                                                                        saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Cmyk;

                                                                                                                                                                                                                                                        // Use custom ICC profiles
                                                                                                                                                                                                                                                        saveOptions.RgbColorProfile = new Aspose.Imaging.Sources.StreamSource(rgbProfileStream);
                                                                                                                                                                                                                                                        saveOptions.CmykColorProfile = new Aspose.Imaging.Sources.StreamSource(cmykProfileStream);

                                                                                                                                                                                                                                                        image.Save(dir + "output.cmyk.jpg", saveOptions);
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                // Load CMYK JPEG and save it to PNG
                                                                                                                                                                                                                                                using (Aspose.Imaging.FileFormats.Jpeg.JpegImage image = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)Image.Load(dir + "output.cmyk.jpg"))
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                    using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
                                                                                                                                                                                                                                                    using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                        // Use custom ICC profiles
                                                                                                                                                                                                                                                        image.RgbColorProfile = new Aspose.Imaging.Sources.StreamSource(rgbProfileStream);
                                                                                                                                                                                                                                                        image.CmykColorProfile = new Aspose.Imaging.Sources.StreamSource(cmykProfileStream);

                                                                                                                                                                                                                                                        Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                                                                                                                        image.Save(dir + "output.rgb.png", saveOptions);
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                }

Sljedeći primjer pokazuje kako stvoriti JPEG sliku određene veličine s određenim parametrima.

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

                                                                                                                    // Create a JPEG image of 100x100 px.
                                                                                                                    // Use additional options to specify the desired image parameters.
                                                                                                                    Aspose.Imaging.ImageOptions.JpegOptions createOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                                    // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
                                                                                                                    createOptions.BitsPerChannel = 8;

                                                                                                                    // Set the progressive type of compression.
                                                                                                                    createOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                                    // Set the image quality. It is a value between 1 and 100.
                                                                                                                    createOptions.Quality = 100;

                                                                                                                    // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                                    createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                                    createOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                                    // This is a standard option for JPEG images.
                                                                                                                    // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
                                                                                                                    createOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.YCbCr;

                                                                                                                    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(createOptions, 100, 100))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpegImage);

                                                                                                                        Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                            new Aspose.Imaging.Point(jpegImage.Width, jpegImage.Height),
                                                                                                                            Aspose.Imaging.Color.Yellow,
                                                                                                                            Aspose.Imaging.Color.Blue);

                                                                                                                        // Fill the image with a grayscale gradient
                                                                                                                        graphics.FillRectangle(gradientBrush, jpegImage.Bounds);

                                                                                                                        // Save to a file.
                                                                                                                        jpegImage.Save(dir + "output.explicitoptions.jpg");
                                                                                                                    }

Comment

Pronađite ili postavite komentar JPEG datoteke.

public string Comment { get; set; }

Vrijednost nekretnina

string

CompressionType

Uzmite ili postavite tip kompresije.

public JpegCompressionMode CompressionType { get; set; }

Vrijednost nekretnina

JpegCompressionMode

Examples

Sljedeći primjer preuzima BMP sliku i čuva je u JPEG-u pomoću različitih opcija spašavanja.

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

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

Sljedeći primjer pokazuje kako stvoriti JPEG sliku određene veličine s određenim parametrima.

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

                                                                                                                    // Create a JPEG image of 100x100 px.
                                                                                                                    // Use additional options to specify the desired image parameters.
                                                                                                                    Aspose.Imaging.ImageOptions.JpegOptions createOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                                    // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
                                                                                                                    createOptions.BitsPerChannel = 8;

                                                                                                                    // Set the progressive type of compression.
                                                                                                                    createOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                                    // Set the image quality. It is a value between 1 and 100.
                                                                                                                    createOptions.Quality = 100;

                                                                                                                    // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                                    createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                                    createOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                                    // This is a standard option for JPEG images.
                                                                                                                    // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
                                                                                                                    createOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.YCbCr;

                                                                                                                    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(createOptions, 100, 100))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpegImage);

                                                                                                                        Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                            new Aspose.Imaging.Point(jpegImage.Width, jpegImage.Height),
                                                                                                                            Aspose.Imaging.Color.Yellow,
                                                                                                                            Aspose.Imaging.Color.Blue);

                                                                                                                        // Fill the image with a grayscale gradient
                                                                                                                        graphics.FillRectangle(gradientBrush, jpegImage.Bounds);

                                                                                                                        // Save to a file.
                                                                                                                        jpegImage.Save(dir + "output.explicitoptions.jpg");
                                                                                                                    }

DefaultMemoryAllocationLimit

Dobiva ili postavlja privremeno ograničenje dodjele memorije.

[Obsolete("Use Aspose.Imaging.Image.BufferSizeHint, Aspose.Imaging.ImageOptionsBase.BufferSizeHint or Aspose.Imaging.LoadOptions.BufferSizeHint instead.")]
public int DefaultMemoryAllocationLimit { get; set; }

Vrijednost nekretnina

int

ExifData

Pronađite ili postavite Exif podatkovni kontejner.

[JsonProperty]
public JpegExifData ExifData { get; set; }

Vrijednost nekretnina

JpegExifData

HorizontalSampling

Dobiva ili postavlja horizontalne podsampljenja za svaku komponentu.

public byte[] HorizontalSampling { get; set; }

Vrijednost nekretnina

byte []

Jfif

Pronađite ili postavite jfif.

public JFIFData Jfif { get; set; }

Vrijednost nekretnina

JFIFData

JpegLsAllowedLossyError

Dobiva ili postavlja JPEG-LS razliku vezan za kodiranje blizu gubitka (NEAR parametar iz JPEG-LS specifikacije).

public int JpegLsAllowedLossyError { get; set; }

Vrijednost nekretnina

int

JpegLsInterleaveMode

Pronađite ili postavite JPEG-LS interleave način.

public JpegLsInterleaveMode JpegLsInterleaveMode { get; set; }

Vrijednost nekretnina

JpegLsInterleaveMode

JpegLsPreset

Pronađite ili postavite parametre JPEG-LS.

public JpegLsPresetCodingParameters JpegLsPreset { get; set; }

Vrijednost nekretnina

JpegLsPresetCodingParameters

PreblendAlphaIfPresent

Dobiva ili postavlja vrijednost koja ukazuje na to treba li se crvene, zelene i plave komponente miješati s bojom pozadine, ako je alfa kanal prisutan.

public bool PreblendAlphaIfPresent { get; set; }

Vrijednost nekretnina

bool

Quality

Dobiti ili postaviti kvalitetu slike.

public int Quality { get; set; }

Vrijednost nekretnina

int

Examples

Sljedeći primjer preuzima BMP sliku i čuva je u JPEG-u pomoću različitih opcija spašavanja.

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

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

Sljedeći primjer pokazuje kako stvoriti JPEG sliku određene veličine s određenim parametrima.

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

                                                                                                                    // Create a JPEG image of 100x100 px.
                                                                                                                    // Use additional options to specify the desired image parameters.
                                                                                                                    Aspose.Imaging.ImageOptions.JpegOptions createOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                                    // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
                                                                                                                    createOptions.BitsPerChannel = 8;

                                                                                                                    // Set the progressive type of compression.
                                                                                                                    createOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                                    // Set the image quality. It is a value between 1 and 100.
                                                                                                                    createOptions.Quality = 100;

                                                                                                                    // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                                    createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                                    createOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                                    // This is a standard option for JPEG images.
                                                                                                                    // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
                                                                                                                    createOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.YCbCr;

                                                                                                                    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(createOptions, 100, 100))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpegImage);

                                                                                                                        Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                            new Aspose.Imaging.Point(jpegImage.Width, jpegImage.Height),
                                                                                                                            Aspose.Imaging.Color.Yellow,
                                                                                                                            Aspose.Imaging.Color.Blue);

                                                                                                                        // Fill the image with a grayscale gradient
                                                                                                                        graphics.FillRectangle(gradientBrush, jpegImage.Bounds);

                                                                                                                        // Save to a file.
                                                                                                                        jpegImage.Save(dir + "output.explicitoptions.jpg");
                                                                                                                    }

RdOptSettings

Pronađite ili postavite RD optimizator postavke.

[JsonProperty]
public RdOptimizerSettings RdOptSettings { get; set; }

Vrijednost nekretnina

RdOptimizerSettings

ResolutionUnit

Uzmite ili postavite jedinicu za rezoluciju.

public ResolutionUnit ResolutionUnit { get; set; }

Vrijednost nekretnina

ResolutionUnit

Examples

Sljedeći primjer preuzima BMP sliku i čuva je u JPEG-u pomoću različitih opcija spašavanja.

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

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

Sljedeći primjer pokazuje kako stvoriti JPEG sliku određene veličine s određenim parametrima.

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

                                                                                                                    // Create a JPEG image of 100x100 px.
                                                                                                                    // Use additional options to specify the desired image parameters.
                                                                                                                    Aspose.Imaging.ImageOptions.JpegOptions createOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                                    // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
                                                                                                                    createOptions.BitsPerChannel = 8;

                                                                                                                    // Set the progressive type of compression.
                                                                                                                    createOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                                    // Set the image quality. It is a value between 1 and 100.
                                                                                                                    createOptions.Quality = 100;

                                                                                                                    // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                                    createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                                    createOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                                    // This is a standard option for JPEG images.
                                                                                                                    // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
                                                                                                                    createOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.YCbCr;

                                                                                                                    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(createOptions, 100, 100))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpegImage);

                                                                                                                        Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                            new Aspose.Imaging.Point(jpegImage.Width, jpegImage.Height),
                                                                                                                            Aspose.Imaging.Color.Yellow,
                                                                                                                            Aspose.Imaging.Color.Blue);

                                                                                                                        // Fill the image with a grayscale gradient
                                                                                                                        graphics.FillRectangle(gradientBrush, jpegImage.Bounds);

                                                                                                                        // Save to a file.
                                                                                                                        jpegImage.Save(dir + "output.explicitoptions.jpg");
                                                                                                                    }

RgbColorProfile

Cilj RGB boja profila za CMYK jpeg slike. koristi za spašavanje slika. mora biti u paru s CMYKColorProfile za ispravnu konverziju boje.

public StreamSource RgbColorProfile { get; set; }

Vrijednost nekretnina

StreamSource

Examples

Sljedeći primjer preuzima PNG i spašava ga na CMYK JPEG pomoću prilagođenog ICC profila. Tada preuzimaju CMYK JPG i sačuvaju ga nazad na RNG. Konverzija boja od RGB do CMYN i od CMYL do RGB obavlja se koristeći prilagojene IP profile.

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

                                                                                                                                                                                                                                                // Load PNG and save it to CMYK JPEG
                                                                                                                                                                                                                                                using (Aspose.Imaging.FileFormats.Png.PngImage image = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Load(dir + "sample.png"))
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                    using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
                                                                                                                                                                                                                                                    using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                        Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
                                                                                                                                                                                                                                                        saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Cmyk;

                                                                                                                                                                                                                                                        // Use custom ICC profiles
                                                                                                                                                                                                                                                        saveOptions.RgbColorProfile = new Aspose.Imaging.Sources.StreamSource(rgbProfileStream);
                                                                                                                                                                                                                                                        saveOptions.CmykColorProfile = new Aspose.Imaging.Sources.StreamSource(cmykProfileStream);

                                                                                                                                                                                                                                                        image.Save(dir + "output.cmyk.jpg", saveOptions);
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                // Load CMYK JPEG and save it to PNG
                                                                                                                                                                                                                                                using (Aspose.Imaging.FileFormats.Jpeg.JpegImage image = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)Image.Load(dir + "output.cmyk.jpg"))
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                    using (System.IO.Stream rgbProfileStream = System.IO.File.OpenRead(dir + "eciRGB_v2.icc"))
                                                                                                                                                                                                                                                    using (System.IO.Stream cmykProfileStream = System.IO.File.OpenRead(dir + "ISOcoated_v2_FullGamut4.icc"))
                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                        // Use custom ICC profiles
                                                                                                                                                                                                                                                        image.RgbColorProfile = new Aspose.Imaging.Sources.StreamSource(rgbProfileStream);
                                                                                                                                                                                                                                                        image.CmykColorProfile = new Aspose.Imaging.Sources.StreamSource(cmykProfileStream);

                                                                                                                                                                                                                                                        Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                                                                                                                        image.Save(dir + "output.rgb.png", saveOptions);
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                }

SampleRoundingMode

Pronađite ili postavite način okretanja uzorka kako biste prilagodili 8-bitnu vrijednost n-bitnoj vrijednosti.JpegOptions.BitsPerChannel

public SampleRoundingMode SampleRoundingMode { get; set; }

Vrijednost nekretnina

SampleRoundingMode

ScaledQuality

i skala kvalitete.

public int ScaledQuality { get; }

Vrijednost nekretnina

int

VerticalSampling

Uzmite ili postavite vertikalne podsampljenja za svaku komponentu.

public byte[] VerticalSampling { get; set; }

Vrijednost nekretnina

byte []

 Hrvatski