Class WebPOptions

Class WebPOptions

Nama dari : Aspose.Imaging.ImageOptions Pengumpulan: Aspose.Imaging.dll (25.4.0)

Mencipta gambar web raster WebP modern menggunakan API kami, dengan dukungan yang kuat untukKompresi tanpa kerugian dan kerugian, serta saluran alfa dan animasi.Meningkatkan konten web Anda dengan visual yang dinamis sambil mengoptimalkan ukuran fileUntuk meningkatkan kecepatan muatan dan pengalaman pengguna.

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

Inheritance

object DisposableObject ImageOptionsBase WebPOptions

Implements

IDisposable , IHasXmpData , IHasMetadata , ICloneable

anggota yang diwarisi

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

Contoh ini menunjukkan cara membuat gambar WebP dari gambar raster lain dengan kualitas kompresi yang berbeda.

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
                                                                                                                      }

Contoh berikut menunjukkan bagaimana untuk menukar gambar vektor multipage ke format WEBP secara umum tanpa merujuk pada jenis gambar tertentu.

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

WebPopsi()

[JsonConstructor]
public WebPOptions()

Properties

AnimBackgroundColor

Dapatkan atau menetapkan warna latar belakang animasi.

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

Nilai Properti

uint

AnimLoopCount

Dapatkan atau menetapkan animasi loop count.

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

Nilai Properti

ushort

Lossless

Dapatkan atau menetapkan nilai yang menunjukkan apakah Aspose.Imaging.ImageOptions.WebPOptions ini tidak kalah.

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

Nilai Properti

bool

Examples

Contoh ini menunjukkan cara membuat gambar WebP dari gambar raster lain dengan kualitas kompresi yang berbeda.

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

Dapatkan atau menetapkan kualitas.

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

Nilai Properti

float

Examples

Contoh ini menunjukkan cara membuat gambar WebP dari gambar raster lain dengan kualitas kompresi yang berbeda.

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