Class WebPOptions

Class WebPOptions

Tên không gian: Aspose.Imaging.ImageOptions Tổng hợp: Aspose.Imaging.dll (25.4.0)

Tạo hình ảnh web WebP raster hiện đại bằng cách sử dụng API của chúng tôi, cung cấp hỗ trợ mạnh mẽ chomất mát và giảm thiểu nén, cũng như các kênh alpha và hoạt hình.Cải thiện nội dung web của bạn với hình ảnh năng động trong khi tối ưu hóa kích thước tệpđể cải thiện tốc độ tải và trải nghiệm người dùng.

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

Inheritance

object DisposableObject ImageOptionsBase WebPOptions

Implements

IDisposable , IHasXmpData , IHasMetadata , ICloneable

Thành viên thừa kế

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

Examples

Ví dụ này cho thấy làm thế nào để tạo một hình ảnh WebP từ một ảnh raster khác với chất lượng nén khác nhau.

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

                                                                                                                      // Load a GIF animation
                                                                                                                      using (Aspose.Imaging.Image image = new Aspose.Imaging.Image.Load(dir + "test.gif"))
                                                                                                                      {
                                                                                                                          // for lossless compression, increasing the quality setting increases the compression quality and decreases the file size
                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_20.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 20 }); // file size: 42 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_50.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 50 }); // file size: 41 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_80.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 80 }); // file size: 40 KB


                                                                                                                          // for lossy compression, increasing the Quality value increases the image quality and increases the file size
                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_20.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 20 }); // file size: 24 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_50.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 50 }); // file size: 36 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_80.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 80 }); // file size: 51 KB
                                                                                                                      }

Ví dụ sau đây cho thấy cách chuyển đổi hình ảnh vector đa trang sang định dạng WEBP nói chung mà không đề cập đến một loại hình hình cụ thể.

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

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

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

                                                                                                                                                                // Export only first two pages. These pages will be presented as animated frames in the output WEBP.
                                                                                                                                                                Aspose.Imaging.IMultipageImage multipageImage = image as Aspose.Imaging.IMultipageImage;
                                                                                                                                                                if (multipageImage != null && (multipageImage.Pages != null && multipageImage.PageCount > 2))
                                                                                                                                                                {
                                                                                                                                                                    exportOptions.MultiPageOptions = new Aspose.Imaging.ImageOptions.MultiPageOptions(new Aspose.Imaging.IntRange(0, 2));
                                                                                                                                                                }

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

                                                                                                                                                                image.Save(outputFilePath, exportOptions);
                                                                                                                                                            }

Constructors

WebPoptions()

[JsonConstructor]
public WebPOptions()

Properties

AnimBackgroundColor

Nhận hoặc đặt màu sắc của nền hoạt hình.

[JsonProperty]
public uint AnimBackgroundColor { get; set; }

Giá trị bất động sản

uint

AnimLoopCount

Nhận hoặc đặt số chuỗi hoạt hình.

[JsonProperty]
public ushort AnimLoopCount { get; set; }

Giá trị bất động sản

ushort

Lossless

Nhận hoặc đặt một giá trị cho thấy liệu đây Aspose.Imaging.ImageOptions.WebPOptions là vô tổn thất.

[JsonProperty]
public bool Lossless { get; set; }

Giá trị bất động sản

bool

Examples

Ví dụ này cho thấy làm thế nào để tạo một hình ảnh WebP từ một ảnh raster khác với chất lượng nén khác nhau.

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

                                                                                                                      // Load a GIF animation
                                                                                                                      using (Aspose.Imaging.Image image = new Aspose.Imaging.Image.Load(dir + "test.gif"))
                                                                                                                      {
                                                                                                                          // for lossless compression, increasing the quality setting increases the compression quality and decreases the file size
                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_20.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 20 }); // file size: 42 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_50.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 50 }); // file size: 41 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_80.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 80 }); // file size: 40 KB


                                                                                                                          // for lossy compression, increasing the Quality value increases the image quality and increases the file size
                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_20.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 20 }); // file size: 24 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_50.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 50 }); // file size: 36 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_80.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 80 }); // file size: 51 KB
                                                                                                                      }

Quality

Nhận hoặc đặt chất lượng.

[JsonProperty]
public float Quality { get; set; }

Giá trị bất động sản

float

Examples

Ví dụ này cho thấy làm thế nào để tạo một hình ảnh WebP từ một ảnh raster khác với chất lượng nén khác nhau.

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

                                                                                                                      // Load a GIF animation
                                                                                                                      using (Aspose.Imaging.Image image = new Aspose.Imaging.Image.Load(dir + "test.gif"))
                                                                                                                      {
                                                                                                                          // for lossless compression, increasing the quality setting increases the compression quality and decreases the file size
                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_20.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 20 }); // file size: 42 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_50.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 50 }); // file size: 41 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossless_80.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = true, Quality = 80 }); // file size: 40 KB


                                                                                                                          // for lossy compression, increasing the Quality value increases the image quality and increases the file size
                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_20.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 20 }); // file size: 24 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_50.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 50 }); // file size: 36 KB

                                                                                                                          image.Save(
                                                                                                                              dir + "output_lossy_80.webp",
                                                                                                                              new  Aspose.Imaging.ImageOptions.WebPOptions() { Lossless = false, Quality = 80 }); // file size: 51 KB
                                                                                                                      }
 Tiếng Việt