Class JpegImage

Class JpegImage

名称: Aspose.Imaging.FileFormats.Jpeg 收藏: Aspose.Imaging.dll (25.4.0)

通过我们的 API 有效地处理 JPEG 拉斯特图像,提供支持不同颜色配置,如 RGB 和 CMYK,可自定义比特每像素EXIF、JFIF 和 XMP 数据集装箱的分辨率和处理。享受基于方向数据的自动旋转,并选择不同的压缩水平,包括无损的JPEG,以实现最佳图像质量并为您的项目提供大小平衡。

[JsonObject(MemberSerialization.OptIn)]
public sealed class JpegImage : RasterCachedImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasJpegExifData, IHasExifData, IHasMetadata

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage RasterCachedImage JpegImage

Implements

IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasJpegExifData , IHasExifData , IHasMetadata

继承人

RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.IsCached , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

访问摄像机制造商在Jpeg图像中的笔记。

using (var image = (JpegImage)Image.Load("Sample.jpg"))
                                                                {
                                                                    foreach (var makerNote in image.ExifData.MakerNotes)
                                                                    {
                                                                        Console.WriteLine("Name = {0}, Value = {1}", makerNote.Name, makerNote.Value);
                                                                    }
                                                                }

示例显示如何从文件上加载 JpegImage。

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

                                                                 // Load a JPEG image from a file.
                                                                 using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(dir + "sample.jpg"))
                                                                 {
                                                                     // Do some image processing.
                                                                     // Save to another JPEG file.
                                                                     jpegImage.Save(dir + "sample.output.jpg");
                                                                 }

Constructors

JpegImage(线条)

Aspose.Imaging.FileFormats.Jpeg.JpegImage 课堂通过呼吁其配有指定的路径参数的构建器. 此构建器允许无缝创建 JPEG 图像,以便快速融入您的项目。

public JpegImage(string path)

Parameters

path string

路径从图像上传并启动像素和面板数据。

Examples

示例显示如何从文件上加载 JpegImage。

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

                                                                 // Load a JPEG image from a file.
                                                                 using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(dir + "sample.jpg"))
                                                                 {
                                                                     // Do some image processing.
                                                                     // Save to another JPEG file.
                                                                     jpegImage.Save(dir + "sample.output.jpg");
                                                                 }

JpegImage(Stream)

以 Aspose.Imaging.FileFormats.Jpeg.JpegImage 类开始使用 JPEG 图像对象流参数. 此构建器简化了使用 JPEG 的过程图像,提供一个简单的方法,将其集成到您的项目毫无努力。

public JpegImage(Stream stream)

Parameters

stream Stream

流从图像上传并启动像素和板块数据。

Examples

示例显示如何从文件流中加载 JpegImage。

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

                                                                        // Load a JPEG image from a file stream.
                                                                        using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.jpg"))
                                                                        {
                                                                            using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(stream))
                                                                            {
                                                                                // Do some image processing.
                                                                                // Save to another JPEG file.
                                                                                jpegImage.Save(dir + "sample.output.jpg");
                                                                            }
                                                                        }

JpegImage(RasterImage)

启动 Aspose.Imaging.FileFormats.Jpeg.JpegImage 类的一个新的例子,用一个拉斯特图像这个构建器提供了一个方便的方式来创建 JPEG 图像直接从拉斯特图像,简化工作流与JPEG图像工作在你的应用中。

public JpegImage(RasterImage rasterImage)

Parameters

rasterImage RasterImage

图像以启动像素和板数据。

Examples

示例显示如何从另一个RasterImage上传JpegImage。

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

                                                                              // Load a JPEG image from another raster image.
                                                                              // First, create a temporal PNG image that will be a foundation for building a JPEG image.
                                                                              // You can also load PNG image from a file or use an image of any other raster format.
                                                                              Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                              createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), false);
                                                                              using (Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(createOptions, 100, 100))
                                                                              {
                                                                                  // Fill the entire PNG image in red.
                                                                                  Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(rasterImage);
                                                                                  Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                  graphics.FillRectangle(brush, rasterImage.Bounds);

                                                                                  // Create a JPEG image based on the PNG image.
                                                                                  using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(rasterImage))
                                                                                  {
                                                                                      // Save to a JPEG file
                                                                                      jpegImage.Save(dir + "output.jpg");
                                                                                  }
                                                                              }

JpegImage(int , int , int)

创建一个新的例子 Aspose.Imaging.FileFormats.Jpeg.JpegImage 类与指定的宽度和高度参数. 这个构建器允许您创建 JPEG 图像定制尺寸,为您提供在应用程序中管理图像尺寸的灵活性。

public JpegImage(int width, int height)

Parameters

width int

图像宽度。

height int

图像高度。

Examples

下面的示例显示如何创建指定的尺寸的JPEG图像。

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

                                                                                      // Create a JPEG image of 100x100 px.
                                                                                      using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(100, 100))
                                                                                      {
                                                                                          // Do some image processing.
                                                                                          // Save to a file.
                                                                                          jpegImage.Save(dir + "output.jpg");
                                                                                      }

下面的示例上传 BMP 图像并将其存储到 JPEG 使用各种存储选项。

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

JpegImage(JpegOptions, int, int)

启动一个新的 Aspose.Imaging.FileFormats.Jpeg.JpegImage 对象与提供的 JPEG 选项。此构建器允许您调整 JPEG 图像的不同设置,如:作为压缩水平、质量和额外的参数,提供准确的控制接下来的图像格式。

public JpegImage(JpegOptions jpegOptions, int width, int height)

Parameters

jpegOptions JpegOptions

JPEG选项。

width int

图像宽度

height int

图像高度。

Examples

下面的示例上传 BMP 图像并将其存储到 JPEG 使用各种存储选项。

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

下面的示例显示如何使用指定的参数创建指定的尺寸的JPEG图像。

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

Properties

BitsPerPixel

用此属性轻松恢复图像的像素深度,提供洞察到色彩或灰色代表性的丰富。活跃的照片或单色图像,这个属性提供关键关于图像的视觉复杂性。

public override int BitsPerPixel { get; }

财产价值

int

CmykColorProfile

与 CMYK 和 YCCK JPEG 图像相关的 CMYK 颜色配置文件确保准确性颜色转换和忠诚度. 它与 RGBColorProfile 合作保证在各种设备和应用程序中准确的颜色代表性。这种配对是保持颜色呈现的一致性至关重要的,以及实现最佳图像质量。

public StreamSource CmykColorProfile { get; set; }

财产价值

StreamSource

Examples

下面的例子将 PNG 加载并将其存储到 CMYK JPEG 使用自定义 ICC 个人资料,然后将 CMYK JPEG 加载并将其存储回 PNG. 从 RGB 到 CMYK 和 从 CMYK 到 RGB 的颜色转换通过自定义 ICC 个人资料进行。

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

Comment

使用此属性管理 JPEG 文件评论,允许您添加或获取描述的标记与图像相关. 它是否标记图像与金属数据或附加背景,此属性提供灵活性组织和分类您的 JPEG 文件。

public string Comment { get; set; }

财产价值

string

DestinationCmykColorProfile

CMYK 颜色配置对 CMYK 和 YCCK 的准确颜色转换至关重要在储蓄过程中使用 JPEG 图像. 它与 RGBColorProfile 同步工作确保正确的颜色代表性,保持一致性和质量不同设备和软件. 此同步是至关重要的实现最终保存的图像中准确和可靠的颜色呈现。

public StreamSource DestinationCmykColorProfile { get; set; }

财产价值

StreamSource

DestinationRgbColorProfile

RGBColorProfile 对于 CMYK 和 YCCK 的准确颜色转换至关重要保存过程中 JPEG 图像. 与 CMYKColorProfile 相匹配时,它确保颜色正确呈现,并保持一致性。各式各樣的裝置和應用程式. 這種組合對保留旨在色彩代表性,并实现高质量的图像输出。

public StreamSource DestinationRgbColorProfile { get; set; }

财产价值

StreamSource

ExifData

使用此属性管理 EXIF 数据,允许您添加或获取代数据与图像相关. 它是否提取有关相机的信息设置或修改现有数据,此属性提供灵活性管理 EXIF 数据集装箱。

public JpegExifData ExifData { get; set; }

财产价值

JpegExifData

Examples

下面的示例显示如何从 JPEG 图像中提取 EXIF 标签。

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

                                                                                  using (Aspose.Imaging.FileFormats.Jpeg.JpegImage image = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)Image.Load(dir + "original.jpg"))
                                                                                  {
                                                                                      Aspose.Imaging.Exif.ExifData exifData = image.ExifData;

                                                                                      System.Console.WriteLine("The general EXIF data");
                                                                                      System.Console.WriteLine("------------------------------------------");
                                                                                      if (exifData != null)
                                                                                      {
                                                                                          System.Console.WriteLine("The EXIF version: {0}", exifData.ExifVersion);
                                                                                          System.Console.WriteLine("The camera serial number: {0}", exifData.BodySerialNumber);
                                                                                          System.Console.WriteLine("The color space: {0}", exifData.ColorSpace);
                                                                                          System.Console.WriteLine("The brightness: {0}", exifData.BrightnessValue);
                                                                                          System.Console.WriteLine("The contrast: {0}", exifData.Contrast);
                                                                                          System.Console.WriteLine("The gamma: {0}", exifData.Gamma);
                                                                                          System.Console.WriteLine("The sharpness: {0}", exifData.Sharpness);
                                                                                          System.Console.WriteLine("The aperture: {0}", exifData.ApertureValue);
                                                                                          System.Console.WriteLine("The exposure mode: {0}", exifData.ExposureMode);
                                                                                          System.Console.WriteLine("The exposure bias: {0}", exifData.ExposureBiasValue);
                                                                                          System.Console.WriteLine("The exposure time: {0}", exifData.ExposureTime);
                                                                                          System.Console.WriteLine("The focal length: {0}", exifData.FocalLength);
                                                                                          System.Console.WriteLine("The focal plane resolution unit: {0}", exifData.FocalPlaneResolutionUnit);
                                                                                          System.Console.WriteLine("The lens model: {0}", exifData.LensModel);
                                                                                          System.Console.WriteLine("The shutter speed: {0}", exifData.ShutterSpeedValue);
                                                                                      }

                                                                                      System.Console.WriteLine("The JPEG EXIF data");
                                                                                      System.Console.WriteLine("------------------------------------------");
                                                                                      Aspose.Imaging.Exif.JpegExifData jpegExifData = image.ExifData as Aspose.Imaging.Exif.JpegExifData;
                                                                                      if (jpegExifData != null)
                                                                                      {
                                                                                          System.Console.WriteLine("The camera manufacturer: {0}", jpegExifData.Make);
                                                                                          System.Console.WriteLine("The camera model: {0}", jpegExifData.Model);
                                                                                          System.Console.WriteLine("The photometric interpretation: {0}", jpegExifData.PhotometricInterpretation);
                                                                                          System.Console.WriteLine("The artist: {0}", jpegExifData.Artist);
                                                                                          System.Console.WriteLine("The copyright: {0}", jpegExifData.Copyright);
                                                                                          System.Console.WriteLine("The image description: {0}", jpegExifData.ImageDescription);
                                                                                          System.Console.WriteLine("The orientation: {0}", jpegExifData.Orientation);
                                                                                          System.Console.WriteLine("The software: {0}", jpegExifData.Software);
                                                                                      }
                                                                                  }

                                                                                  //The output looks like this:
                                                                                  //The general EXIF data
                                                                                  //------------------------------------------
                                                                                  //The EXIF version: System.Byte[]
                                                                                  //The camera serial number: 7100536
                                                                                  //The color space: SRgb
                                                                                  //The brightness:
                                                                                  //The contrast: Normal
                                                                                  //The gamma:
                                                                                  //The sharpness: 0
                                                                                  //The aperture: 4.64(4643856 / 1000000)
                                                                                  //The exposure mode: Manual
                                                                                  //The exposure bias: 0.67(4 / 6)
                                                                                  //The exposure time: 0.01(1 / 160)
                                                                                  //The focal length: 145.00(1450 / 10)
                                                                                  //The focal plane resolution unit: Cm
                                                                                  //The lens model: 70.0 - 200.0 mm f/ 4.0
                                                                                  //The shutter speed: 7.32(7321928 / 1000000)
                                                                                  //The JPEG EXIF data
                                                                                  //------------------------------------------
                                                                                  //The camera manufacturer: NIKON CORPORATION
                                                                                  //The camera model: NIKON D5
                                                                                  //The photometric interpretation: 0
                                                                                  //The artist: 
                                                                                  //The copyright: 
                                                                                  //The image description:
                                                                                  //The orientation: TopLeft
                                                                                  //The software: Adobe Photoshop Camera Raw 9.9(Macintosh)

FileFormat

用此属性轻松恢复图像格式。对文件格式有价值的见解,有助于无缝集成和通过各种平台和应用程序进行兼容性检查。

public override FileFormat FileFormat { get; }

财产价值

FileFormat

Height

用此属性轻松恢复图像的高度,提供快速访问图像的垂直尺寸,使您能够有效地确定其尺寸和方面比例,而无需进行复杂的计算或其他方法。

public override int Height { get; }

财产价值

int

HorizontalResolution

此属性允许您访问地平线分辨率Aspose.Imaging.RasterImage,按英寸的像素测量。这个值,你可以准确控制图像的分辨率,确保它满足您对质量和清晰度的具体要求。

public override double HorizontalResolution { get; set; }

财产价值

double

Examples

下面的示例显示如何设置 JPEG 图像的水平/垂直分辨率。

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

                                                                                                 using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
                                                                                                 {
                                                                                                     Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)image;

                                                                                                     // Get horizontal and vertical resolution of the BmpImage
                                                                                                     double horizontalResolution = jpegImage.HorizontalResolution;
                                                                                                     double verticalResolution = jpegImage.VerticalResolution;
                                                                                                     System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                     System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                     if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                     {
                                                                                                         // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                         System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                         jpegImage.SetResolution(96.0, 96.0);

                                                                                                         System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", jpegImage.HorizontalResolution);
                                                                                                         System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", jpegImage.VerticalResolution);
                                                                                                     }

                                                                                                     // The output may look like this:
                                                                                                     // The horizontal resolution, in pixels per inch: 300
                                                                                                     // The vertical resolution, in pixels per inch: 300
                                                                                                     // Set resolution values to 96 dpi
                                                                                                     // The horizontal resolution, in pixels per inch: 96
                                                                                                     // The vertical resolution, in pixels per inch: 96
                                                                                                 }

Remarks

默认情况下,这个值总是 96 因为不同的平台无法返回屏幕分辨率. 您可以考虑使用 SetResolution 方法在单个通话中更新两个分辨率值。

IgnoreEmbeddedColorProfile

返回或修改旗帜表示是否内置的颜色配置通过设置此旗帜,用户可以指定是否默认颜色配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置配置控制颜色管理,促进一致性调整和不同平台和应用程序的兼容性。

public bool IgnoreEmbeddedColorProfile { get; set; }

财产价值

bool

Jfif

此属性允许您访问或修改 JFIF (JPEG 文件交换)格式)与 JPEG 图像相关的数据. JFIF 是标准格式交换 JPEG 压缩图像在计算机和其他设备之间。或设置此属性,您可以与 JFIF 数据进行互动,其中可能包括如图像的分辨率、视角比率和微小等信息。

public JFIFData Jfif { get; set; }

财产价值

JFIFData

JpegOptions

获取在创建或加载此选项时使用的 JPEG 选项的访问Aspose.Imaging.FileFormats.Jpeg.JpegImage 例子很容易。关于使用的具体设置,使用户能够理解和复制图像处理工作流有效. 无论是压缩水平,质量设置,或其他参数,本属性提供必需的洞察力无形图像操纵。

public JpegOptions JpegOptions { get; }

财产价值

JpegOptions

Examples

下面的示例显示如何从 JPEG 图像中提取标题信息。

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

                                                                                               using (Aspose.Imaging.FileFormats.Jpeg.JpegImage image = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)Image.Load(dir + "original.jpg"))
                                                                                               {
                                                                                                   Aspose.Imaging.ImageOptions.JpegOptions jpegOptions = image.JpegOptions;

                                                                                                   System.Console.WriteLine("The number of bits per channel: {0}", jpegOptions.BitsPerChannel);
                                                                                                   System.Console.WriteLine("The max allowed size for all internal buffers: {0}", jpegOptions.BufferSizeHint);
                                                                                                   System.Console.WriteLine("The color type: {0}", jpegOptions.ColorType);
                                                                                                   System.Console.WriteLine("The compression type: {0}", jpegOptions.CompressionType);
                                                                                                   System.Console.WriteLine("The image quality: {0}", jpegOptions.Quality);

                                                                                                   if (jpegOptions.ResolutionSettings != null)
                                                                                                   {
                                                                                                       System.Console.WriteLine("The horizontal resolution: {0}", jpegOptions.ResolutionSettings.HorizontalResolution);
                                                                                                       System.Console.WriteLine("The vertical resolution: {0}", jpegOptions.ResolutionSettings.VerticalResolution);
                                                                                                   }

                                                                                                   for (int i = 0; i < jpegOptions.HorizontalSampling.Length; i++)
                                                                                                   {
                                                                                                       System.Console.WriteLine("The sampling for component {0}: {1}x{2}", i, jpegOptions.HorizontalSampling[i], jpegOptions.VerticalSampling[i]);
                                                                                                   }
                                                                                               }

                                                                                               //The output looks like this:
                                                                                               //The number of bits per channel: 8
                                                                                               //The max allowed size for all internal buffers: 0
                                                                                               //The color type: YCbCr
                                                                                               //The compression type: Baseline
                                                                                               //The image quality: 75
                                                                                               //The sampling for component 0: 1x1
                                                                                               //The sampling for component 1: 1x1
                                                                                               //The sampling for component 2: 1x1

RawDataFormat

此属性获取图像的原始数据格式,这表明图像的原始数据格式图像数据是结构化和编码的. 理解原始数据格式是对图像数据的有效处理或操纵至关重要。了解图像的基本代表性,例如它是否压缩,在特定颜色空间中编码,或存储在特定文件中格式. 访问此属性允许您获取有关图像的数据结构,允许您执行各种操作或优化适合其特定的格式。

public override PixelDataFormat RawDataFormat { get; }

财产价值

PixelDataFormat

RgbColorProfile

CMYK 和 YCCK JPEG 图像的 RGB 颜色配置为准确的颜色转换和代表性. 必须与 CMYKColorProfile 相匹配保持色彩呈现的一致性和忠诚度,这种配对是必不可少的需要精确的颜色管理和图像复制的应用程序,确保 RGB 数据被正确解释和显示。

public StreamSource RgbColorProfile { get; set; }

财产价值

StreamSource

Examples

下面的例子将 PNG 加载并将其存储到 CMYK JPEG 使用自定义 ICC 个人资料,然后将 CMYK JPEG 加载并将其存储回 PNG. 从 RGB 到 CMYK 和 从 CMYK 到 RGB 的颜色转换通过自定义 ICC 个人资料进行。

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

VerticalResolution

此属性管理垂直分辨率,以每英寸的像素表达,为相关的 Aspose.Imaging.RasterImage. 调整此分辨率会影响图像的尺寸和质量,当以固定物理尺寸打印或显示时。通过设置此属性,您可以控制图像的像素包装的密度。垂直,影响其整体清晰度和清晰度。

public override double VerticalResolution { get; set; }

财产价值

double

Examples

下面的示例显示如何设置 JPEG 图像的水平/垂直分辨率。

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

                                                                                                 using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
                                                                                                 {
                                                                                                     Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)image;

                                                                                                     // Get horizontal and vertical resolution of the BmpImage
                                                                                                     double horizontalResolution = jpegImage.HorizontalResolution;
                                                                                                     double verticalResolution = jpegImage.VerticalResolution;
                                                                                                     System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                     System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                     if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                     {
                                                                                                         // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                         System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                         jpegImage.SetResolution(96.0, 96.0);

                                                                                                         System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", jpegImage.HorizontalResolution);
                                                                                                         System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", jpegImage.VerticalResolution);
                                                                                                     }

                                                                                                     // The output may look like this:
                                                                                                     // The horizontal resolution, in pixels per inch: 300
                                                                                                     // The vertical resolution, in pixels per inch: 300
                                                                                                     // Set resolution values to 96 dpi
                                                                                                     // The horizontal resolution, in pixels per inch: 96
                                                                                                     // The vertical resolution, in pixels per inch: 96
                                                                                                 }

Remarks

默认情况下,这个值总是 72 因为不同的平台无法返回屏幕分辨率. 您可以考虑使用 SetResolution 方法在单个通话中更新两个分辨率值。

Width

此属性获取图像的宽度,以像素表达。关于图像的尺寸的基本信息,以便准确的呈现,操作,或显示图像数据。

public override int Width { get; }

财产价值

int

XmpData

获取或设置XMP代数据,可无缝集成描述信息进入图像文件. 您是否正在提取现有 XMP代数据或更新它与新的信息,这个属性简化了管理扩展的数据,确保与各种应用的兼容性以及工作流。

public override XmpPacketWrapper XmpData { get; set; }

财产价值

XmpPacketWrapper

Methods

AutoRotate()

自动旋转基于从 Exif 提取的导向数据的图像这种方法确保图像显示在正确的方向,提高用户体验,消除手动调整的需要。分析 Exif 信息,图像按顺序旋转,提供无缝在不同平台和设备上查看体验. 此自动旋转该过程简化了图像处理,并提高了整体可用性,特别是当处理不同方向的图像大堆。

public void AutoRotate()

Exceptions

ArgumentOutOfRangeException

“JpegExifData”的“导向”值不属于允许范围(1…8),因此不能自动旋转。

GetModifyDate(博尔)

恢复资源图像最新的日期和时间此方法提供有价值的代数据,允许用户跟踪和有效管理图像文件的更新. 通过访问此信息,用户能够确保其图像资产的完整性和货币,便于提供信息。关于图像使用和维护的决策。

public override DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

如果设置为“真实”,则使用 FileInfo 的信息作为默认值。

Returns

DateTime

资源图像的日期和时间最后修改。

ReleaseManagedResources()

释放管理资源 确保没有未管理资源在这里释放,因为它们可能已经释放了。

protected override void ReleaseManagedResources()

RemoveMetadata()

删除此图像示例 meta 数据 通过设置此 Aspose.Imaging.Xmp.IHasXMPData.xmp Data 和 _ www.exif.ihas Exif。 .

public override void RemoveMetadata()

SaveData(Stream)

保存数据。

protected override void SaveData(Stream stream)

Parameters

stream Stream

流来保存数据。

SetResolution(双,双)

设置指定的 Aspose.Imaging.RasterImage 的分辨率,确保精确的尺寸和打印能力. 这种方法允许用户调整图像分辨率符合其具体要求,无论是数字显示或物理复制. 通过设置分辨率,用户可以优化图像质量,并确保与不同输出设备和媒体的兼容性,提高图像的整体视觉体验和可用性。

public override void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

垂直分辨率,每英寸点,的Aspose.Imaging.RasterImage。

dpiY double

垂直分辨率,每英寸点,的Aspose.Imaging.RasterImage。

Examples

下面的示例显示如何设置 JPEG 图像的水平/垂直分辨率。

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

                                                                                                 using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
                                                                                                 {
                                                                                                     Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)image;

                                                                                                     // Get horizontal and vertical resolution of the BmpImage
                                                                                                     double horizontalResolution = jpegImage.HorizontalResolution;
                                                                                                     double verticalResolution = jpegImage.VerticalResolution;
                                                                                                     System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                     System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                     if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                     {
                                                                                                         // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                         System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                         jpegImage.SetResolution(96.0, 96.0);

                                                                                                         System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", jpegImage.HorizontalResolution);
                                                                                                         System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", jpegImage.VerticalResolution);
                                                                                                     }

                                                                                                     // The output may look like this:
                                                                                                     // The horizontal resolution, in pixels per inch: 300
                                                                                                     // The vertical resolution, in pixels per inch: 300
                                                                                                     // Set resolution values to 96 dpi
                                                                                                     // The horizontal resolution, in pixels per inch: 96
                                                                                                     // The vertical resolution, in pixels per inch: 96
                                                                                                 }

UpdateDimensions(int , int , int)

更新图像尺寸。

protected override void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

新图像宽度。

newHeight int

新图像高度。

UpdateMetadata()

更新图像数据。

protected override void UpdateMetadata()
 中文