Class JpegImage
Tên không gian: Aspose.Imaging.FileFormats.Jpeg Tổng hợp: Aspose.Imaging.dll (25.4.0)
Hiệu quả xử lý hình ảnh raster JPEG với API của chúng tôi, cung cấp hỗ trợcho các hồ sơ màu khác nhau như RGB và CMYK, bits tùy chỉnh mỗi pixelĐộ phân giải và xử lý các container EXIF, JFIF và XMP.Thưởng thức tự động xoay dựa trên dữ liệu định hướng và chọn từ các khác nhauMức độ nén, bao gồm JPEG không mất mát, để đạt được chất lượng hình ảnh tối ưuvà file size balance cho các dự án của bạn.
[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
Thành viên thừa kế
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
Truy cập máy ảnh nhà sản xuất ghi chú trong Jpeg hình ảnh.
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);
}
}
Ví dụ cho thấy làm thế nào để tải một JpegImage từ một tệp.
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(String)
Các lớp Aspose.Imaging.FileFormats.Jpeg.JPEGImage bắt đầu vô cùng nỗ lực bằng cách kêu gọinhà xây dựng với các thông số con đường được chỉ định. nhà tạo này cho phép không thấmtạo hình ảnh JPEG, đảm bảo tích hợp nhanh chóng vào các dự án của bạn dễ dàng.
public JpegImage(string path)
Parameters
path
string
Con đường để tải hình ảnh từ và bắt đầu pixel và palette dữ liệu với.
Examples
Ví dụ cho thấy làm thế nào để tải một JpegImage từ một tệp.
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)
Bắt đầu một đối tượng hình ảnh JPEG với Aspose.Imaging.FileFormats.Jpeg.JPEGImage lớp bằng cách sử dụng mộtparameter stream.Constructor này đơn giản hóa quá trình làm việc với JPEGhình ảnh, cung cấp một cách tiếp cận đơn giản để tích hợp chúng vào các dự án của bạnkhông cố gắng.
public JpegImage(Stream stream)
Parameters
stream
Stream
Các dòng để tải hình ảnh từ và bắt đầu pixel và dữ liệu palette với.
Examples
Ví dụ cho thấy làm thế nào để tải một JpegImage từ một dòng tệp.
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)
Bắt đầu một trường hợp mới của lớp Aspose.Imaging.FileFormats.Jpeg.JPEGImage với một hình ảnh rasterParameter.Constructor này cung cấp một cách thuận tiện để tạo hình ảnh JPEGtrực tiếp từ các hình ảnh raster, làm nhanh dòng công việc để làm việc với các ảnh JPEGtrong các ứng dụng của bạn.
public JpegImage(RasterImage rasterImage)
Parameters
rasterImage
RasterImage
Hình ảnh để bắt đầu pixel và palette dữ liệu với.
Examples
Ví dụ này cho thấy làm thế nào để tải một JpegImage từ một Raster Image khác.
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)
Tạo một ví dụ mới của lớp Aspose.Imaging.FileFormats.Jpeg.Những hình ảnh với chiều rộng cụ thểvà các thông số chiều cao.Constructor này cho phép bạn tạo hình ảnh JPEG vớiKích thước tùy chỉnh, cho bạn sự linh hoạt trong việc quản lý kích thước hình ảnh trong ứng dụng của bạn.
public JpegImage(int width, int height)
Parameters
width
int
Hình ảnh rộng.
height
int
Độ cao hình ảnh
Examples
Ví dụ sau đây cho thấy làm thế nào để tạo hình ảnh JPEG của kích thước cụ thể.
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");
}
Ví dụ sau đây tải một hình ảnh BMP và lưu nó vào JPEG bằng cách sử dụng các tùy chọn lưu khác nhau.
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)
Bắt đầu một đối tượng mới Aspose.Imaging.FileFormats.Jpeg.JPegImage với các tùy chọn JPEG được cung cấp.Máy xây dựng này cho phép bạn điều chỉnh các cài đặt khác nhau cho hình ảnh JPEG, như:như mức độ nén, chất lượng, và các thông số bổ sung, cho phép kiểm soát chính xácqua định dạng hình ảnh kết quả.
public JpegImage(JpegOptions jpegOptions, int width, int height)
Parameters
jpegOptions
JpegOptions
Các lựa chọn của jpeg
width
int
Hình ảnh rộng
height
int
độ cao hình ảnh
Examples
Ví dụ sau đây tải một hình ảnh BMP và lưu nó vào JPEG bằng cách sử dụng các tùy chọn lưu khác nhau.
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);
}
Ví dụ sau đây cho thấy làm thế nào để tạo hình ảnh JPEG của kích thước cụ thể với các thông số được chỉ định.
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
Khôi phục độ sâu pixel của hình ảnh một cách dễ dàng với tài sản này, cung cấphiểu biết về sự phong phú của màu sắc hoặc đại diện màu xám. cho dù nó là mộthình ảnh sôi động hoặc một minh họa monochrome, tài sản này cung cấp quan trọngthông tin về sự phức tạp của hình ảnh.
public override int BitsPerPixel { get; }
Giá trị bất động sản
CmykColorProfile
Hồ sơ màu CMYK được kết hợp với hình ảnh JPEG CMYK và YCCK đảm bảo độ chính xácchuyển đổi màu và sự trung thành. nó hoạt động cùng với RGBColorProfile đểđảm bảo sự đại diện màu chính xác trên các thiết bị và ứng dụng khác nhau.Sự kết hợp này rất quan trọng để duy trì sự nhất quán trong rendering màu sắc vàđạt được chất lượng hình ảnh tối ưu.
public StreamSource CmykColorProfile { get; set; }
Giá trị bất động sản
Examples
Ví dụ sau đây tải PNG và tiết kiệm nó đến CMYK JPEG bằng cách sử dụng hồ sơ ICC tùy chỉnh. Sau đó tải CMYK JPeg và lưu lại nó trở lại Png. Chuyển đổi màu từ RGB sang CMYN và từ CMYL sang RG được thực hiện bằng các hồ sưu tập ICR tùy chọn.
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
Quản lý các bình luận tệp JPEG với tài sản này, cho phép bạn thêm hoặc lấy lạicác ghi chú mô tả liên quan đến hình ảnh. cho dù nó là đánh dấu ảnh vớimetadata hoặc mở ra một bối cảnh bổ sung, tài sản này cung cấp sự linh hoạt trongsắp xếp và phân loại các tệp JPEG của bạn.
public string Comment { get; set; }
Giá trị bất động sản
DestinationCmykColorProfile
Hồ sơ màu CMYK rất quan trọng cho sự chuyển đổi màu chính xác của CMYK và YCCK.Hình ảnh JPEG trong quá trình tiết kiệm. nó hoạt động đồng bộ với RGBColorProfileđể đảm bảo sự đại diện màu chính xác, duy trì sự nhất quán và chất lượng giữacác thiết bị và phần mềm khác nhau. đồng bộ hóa này là rất quan trọng để đạt đượcĐộ chính xác và đáng tin cậy rendering màu sắc trong hình ảnh cuối cùng được tiết kiệm.
public StreamSource DestinationCmykColorProfile { get; set; }
Giá trị bất động sản
DestinationRgbColorProfile
RGBColorProfile là cần thiết cho sự chuyển đổi màu chính xác của CMYK và YCCKHình ảnh JPEG trong quá trình tiết kiệm.Khi kết hợp với CMYKColorProfile, nóđảm bảo rằng màu sắc được thực hiện đúng cách và duy trì sự nhất quán giữacác thiết bị và ứng dụng khác nhau. sự kết hợp này rất quan trọng để duy trìmục đích biểu diễn màu sắc và đạt được hình ảnh chất lượng cao.
public StreamSource DestinationRgbColorProfile { get; set; }
Giá trị bất động sản
ExifData
Quản lý dữ liệu EXIF với tài sản này, cho phép bạn thêm hoặc thu thập metadataliên quan đến hình ảnh. cho dù nó thu thập thông tin về máy ảnhcài đặt hoặc sửa đổi các metadata hiện có, tài sản này cung cấp tính linh hoạt trongQuản lý container dữ liệu EXIF.
public JpegExifData ExifData { get; set; }
Giá trị bất động sản
Examples
Ví dụ sau đây cho thấy làm thế nào để lấy thẻ EXIF từ một hình ảnh JPEG.
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
Khôi phục định dạng của hình ảnh một cách dễ dàng với tài sản này. nó cung cấphiểu biết có giá trị về định dạng tệp, hỗ trợ trong việc tích hợp không dây vàKiểm tra sự tương thích trên các nền tảng và ứng dụng khác nhau.
public override FileFormat FileFormat { get; }
Giá trị bất động sản
Height
Khôi phục chiều cao của hình ảnh một cách dễ dàng với tài sản này. nó cung cấp nhanhtruy cập vào chiều cao dọc của hình ảnh, cho phép bạn hiệu quảxác định tỷ lệ kích thước và khía cạnh của nó mà không cần tính toán phức tạp hoặcCác phương pháp bổ sung
public override int Height { get; }
Giá trị bất động sản
HorizontalResolution
Tài sản này cho phép bạn truy cập vào độ phân giải ngang củaAspose.Imaging.RasterImage, đo bằng pixel/inch. bằng cách thiết lập hoặc lấy lạigiá trị này, bạn có thể kiểm soát chính xác độ phân giải của hình ảnh, đảm bảo nóđáp ứng các yêu cầu cụ thể của bạn về chất lượng và độ rõ ràng.
public override double HorizontalResolution { get; set; }
Giá trị bất động sản
Examples
Ví dụ sau đây cho thấy làm thế nào để thiết lập độ phân giải ngang / dọc của một hình ảnh 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
Ghi chú theo mặc định giá trị này luôn 96 vì các nền tảng khác nhau không thể trả lại độ phân giải màn hình. Bạn có thể xem xét sử dụng phương pháp SetResolution để cập nhật cả hai giá trị độ phân giải trong một cuộc gọi.
IgnoreEmbeddedColorProfile
Chuyển đổi hoặc sửa đổi lá cờ cho biết liệu hồ sơ màu được nhúng làBằng cách đặt lá cờ này, người dùng có thể xác định màu mặc định hay không.profile nên được sử dụng thay vì trong một. tùy chọn này đảm bảo lớn hơnkiểm soát quản lý màu sắc, tạo điều chỉnh cho sự nhất quán vàtương thích trên các nền tảng và ứng dụng khác nhau.
public bool IgnoreEmbeddedColorProfile { get; set; }
Giá trị bất động sản
Jfif
Tài sản này cho phép bạn truy cập hoặc sửa đổi JFIF (JPEG File Interchange)Định dạng) dữ liệu liên quan đến hình ảnh JPEG. JFIF là định dạng tiêu chuẩn chotrao đổi hình ảnh nén JPEG giữa máy tính và các thiết bị khác.hoặc thiết lập tài sản này, bạn có thể tương tác với dữ liệu JFIF, trong đó cóthông tin như độ phân giải của hình ảnh, tỷ lệ khía cạnh, và nhỏ.
public JFIFData Jfif { get; set; }
Giá trị bất động sản
JpegOptions
Nhận quyền truy cập vào các tùy chọn JPEG được sử dụng trong quá trình tạo hoặc tải nóAspose.Imaging.FileFormats.Jpeg.Thuyết minh ví dụ với dễ dàng. tài sản này cung cấp chi tiết có giá trịvề các cài đặt cụ thể được sử dụng, cho phép người dùng hiểu và lặp lạihình ảnh xử lý dòng công việc hiệu quả. cho dù đó là mức độ nén, chất lượngcài đặt, hoặc các thông số khác, tài sản này cung cấp những hiểu biết thiết yếu vềHình ảnh vô hình manipulation.
public JpegOptions JpegOptions { get; }
Giá trị bất động sản
Examples
Ví dụ sau đây cho thấy làm thế nào để thu thập thông tin tiêu đề từ hình ảnh 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
Tài sản này lấy lại định dạng dữ liệu thô của hình ảnh, cho thấy cáchDữ liệu hình ảnh được cấu trúc và mã hóa. Hiểu định dạng dữ liệu thô làcần thiết để xử lý hoặc thao túng dữ liệu hình ảnh một cách hiệu quả.hiểu biết về đại diện cơ bản của hình ảnh, chẳng hạn như liệu nó cónén, mã hóa trong không gian màu cụ thể, hoặc lưu trữ trong một tệp nhất địnhTruy cập tài sản này cho phép bạn nhận được thông tin có giá trị vềcấu trúc dữ liệu của hình ảnh, cho phép bạn thực hiện các hoạt động hoặc tối ưu hóa khác nhauphù hợp với định dạng cụ thể của nó.
public override PixelDataFormat RawDataFormat { get; }
Giá trị bất động sản
RgbColorProfile
Hồ sơ màu RGB cho hình ảnh CMYK và YCCK JPEG đảm bảo màu sắc chính xácchuyển đổi và đại diện. nó phải được kết hợp với CMYKColorProfile đểduy trì sự nhất quán và trung thành trong rendering màu sắc. cặp này là cần thiết chocác ứng dụng yêu cầu quản lý màu sắc chính xác và tái tạo hình ảnh,đảm bảo rằng dữ liệu RGB được giải thích và hiển thị đúng cách.
public StreamSource RgbColorProfile { get; set; }
Giá trị bất động sản
Examples
Ví dụ sau đây tải PNG và tiết kiệm nó đến CMYK JPEG bằng cách sử dụng hồ sơ ICC tùy chỉnh. Sau đó tải CMYK JPeg và lưu lại nó trở lại Png. Chuyển đổi màu từ RGB sang CMYN và từ CMYL sang RG được thực hiện bằng các hồ sưu tập ICR tùy chọn.
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
Tài sản này quản lý độ phân giải dọc, được thể hiện trong pixels per inch, choliên kết Aspose.Imaging.RasterImage. điều chỉnh độ phân giải này ảnh hưởng đếnKích thước và chất lượng của hình ảnh khi in hoặc hiển thị với kích thước vật lý cố định.Bằng cách thiết lập tài sản này, bạn kiểm soát độ dày của các pixel của hình ảnh được đóng gói như thế nàodọc, ảnh hưởng đến độ sắc nét và rõ ràng tổng thể của nó.
public override double VerticalResolution { get; set; }
Giá trị bất động sản
Examples
Ví dụ sau đây cho thấy làm thế nào để thiết lập độ phân giải ngang / dọc của một hình ảnh 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
Ghi chú theo mặc định giá trị này luôn là 72 vì các nền tảng khác nhau không thể trả lại độ phân giải màn hình. Bạn có thể xem xét sử dụng phương pháp SetResolution để cập nhật cả hai mức độ trong một cuộc gọi.
Width
Tài sản này thu thập chiều rộng của hình ảnh, được thể hiện trong pixels.thông tin thiết yếu về kích thước của hình ảnh, cho phép rendering chính xác,thao tác, hoặc hiển thị dữ liệu hình ảnh.
public override int Width { get; }
Giá trị bất động sản
XmpData
Nhận hoặc thiết lập các metadata XMP, cho phép sự tích hợp không dây củathông tin mô tả vào tệp hình ảnh. cho dù bạn đang rút XMP hiện cómetadata hoặc cập nhật nó với thông tin mới, tài sản này đơn giản hóaquản lý các metadata mở rộng, đảm bảo tương thích với các ứng dụng khác nhauvà dòng công việc.
public override XmpPacketWrapper XmpData { get; set; }
Giá trị bất động sản
Methods
AutoRotate()
Tự động xoay hình ảnh dựa trên dữ liệu định hướng được lấy từ ExifPhương pháp này đảm bảo rằng hình ảnh được hiển thị trong định hướng chính xác,cải thiện trải nghiệm người dùng và loại bỏ nhu cầu điều chỉnh thủ công.phân tích thông tin Exif, hình ảnh được xoay theo đó, cung cấp mộttrải nghiệm xem trên các nền tảng và thiết bị khác nhau. xoay tự động nàyquy trình làm đơn giản hóa xử lý hình ảnh và cải thiện khả năng sử dụng tổng thể, đặc biệt là khixử lý các bộ sưu tập lớn của hình ảnh với định hướng khác nhau.
public void AutoRotate()
Exceptions
Giá trị ‘Giả hướng’ của ‘JpegExifData’ nằm ngoài phạm vi cho phép [1…8], vì vậy tự xoay không thể được áp dụng.
GetModifyDate(Bool)
Xét lại ngày và thời gian khi hình ảnh nguồn đã trải qua ngày mới nhất của nóphương pháp này cung cấp các metadata có giá trị, cho phép người dùng theo dõi vàquản lý các bản cập nhật cho tệp hình ảnh một cách hiệu quả. bằng cách truy cập thông tin này, người dùngcó thể đảm bảo tính toàn vẹn và tiền tệ của tài sản hình ảnh của họ, tạo điều kiện cho thông tinQuyết định về việc sử dụng và duy trì hình ảnh.
public override DateTime GetModifyDate(bool useDefault)
Parameters
useDefault
bool
nếu được thiết lập để ’truyền’ sử dụng thông tin từ FileInfo như là giá trị mặc định.
Returns
Ngày và thời gian hình ảnh nguồn được sửa đổi lần cuối.
ReleaseManagedResources()
Hãy chắc chắn rằng không có tài nguyên không được quản lý được phát hành ở đây, vì chúng có thể đã được phát hành.
protected override void ReleaseManagedResources()
RemoveMetadata()
Xóa các metadata mẫu hình này bằng cách thiết lập các giá trị này Aspose.Imaging.Xmp.IHasXmphData.xmpdata và Wl17.Exif.IHasexifDate. 0 0 0.
public override void RemoveMetadata()
SaveData(Stream)
Tiết kiệm dữ liệu
protected override void SaveData(Stream stream)
Parameters
stream
Stream
Stream để lưu dữ liệu đến.
SetResolution(đôi, double)
Thiết lập độ phân giải cho Aspose.Imaging.RasterImage, đảm bảokhả năng quy mô và in chính xác. phương pháp này cho phép người dùng điều chỉnhđộ phân giải hình ảnh để phù hợp với các yêu cầu cụ thể của họ, cho dù đối với kỹ thuật sốhiển thị hoặc tái tạo vật lý. bằng cách thiết lập độ phân giải, người dùng có thể tối ưu hóaChất lượng hình ảnh và đảm bảo sự tương thích với các thiết bị và phương tiện phát hành khác nhau,Tăng cường trải nghiệm thị giác tổng thể và khả năng sử dụng của hình ảnh.
public override void SetResolution(double dpiX, double dpiY)
Parameters
dpiX
double
Độ phân giải ngang, ở điểm mỗi inch, của Aspose.Imaging.RasterImage.
dpiY
double
Độ phân giải dọc, ở điểm mỗi inch, của Aspose.Imaging.RasterImage.
Examples
Ví dụ sau đây cho thấy làm thế nào để thiết lập độ phân giải ngang / dọc của một hình ảnh 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)
Cập nhật kích thước hình ảnh.
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
Hình ảnh mới rộng.
newHeight
int
Độ cao hình ảnh mới.
UpdateMetadata()
Cập nhật hình ảnh metadata.
protected override void UpdateMetadata()