Class WebPOptions
ja nimityö: Aspose.Imaging.ImageOptions Kokoelma: Aspose.Imaging.dll (25.4.0)
Luo nykyaikaiset WebP raster web-kuvat käyttämällä API:tä, jolla on vahva tukitappamaton ja tappio kompressi, sekä alfa-kanavat ja animaatiot.Paranna web-sisältöä dynaamisilla visuaaleilla ja optimoi tiedostojen koonparannetaan latausnopeutta ja käyttäjäkokemusta.
[JsonObject(MemberSerialization.OptIn)]
public class WebPOptions : ImageOptionsBase, IDisposable, IHasXmpData, IHasMetadata, ICloneable
Inheritance
object ← DisposableObject ← ImageOptionsBase ← WebPOptions
Implements
IDisposable , IHasXmpData , IHasMetadata , ICloneable
Perintöjäsenet
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
Tämä esimerkki osoittaa, miten luoda WebP-kuva toisesta rasterista, jossa on erilainen kompressiokapasiteetti.
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
}
Seuraava esimerkki näyttää, miten muuntaa monisivuinen vektorikuva WEBP-muodossa yleensä viittaamatta tiettyyn kuvan tyyppiin.
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
Webpisteitä()
[JsonConstructor]
public WebPOptions()
Properties
AnimBackgroundColor
Antaa tai asettaa animaation taustan väri.
[JsonProperty]
public uint AnimBackgroundColor { get; set; }
Omistuksen arvo
AnimLoopCount
Ansaitse tai aseta animaation kierroksen lasku.
[JsonProperty]
public ushort AnimLoopCount { get; set; }
Omistuksen arvo
Lossless
Saat tai asettaa arvon, joka osoittaa, onko tämä Aspose.Imaging.ImageOptions.WebPOptions on tappamaton.
[JsonProperty]
public bool Lossless { get; set; }
Omistuksen arvo
Examples
Tämä esimerkki osoittaa, miten luoda WebP-kuva toisesta rasterista, jossa on erilainen kompressiokapasiteetti.
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
Saa tai asettaa laatu.
[JsonProperty]
public float Quality { get; set; }
Omistuksen arvo
Examples
Tämä esimerkki osoittaa, miten luoda WebP-kuva toisesta rasterista, jossa on erilainen kompressiokapasiteetti.
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
}