←Select platform

CodecsWebpSaveOptions Class

Summary
Provides options specifically for saving WebP images.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public class CodecsWebpSaveOptions 
@interface LTCodecsWebpSaveOptions : NSObject 
public class CodecsWebpSaveOptions 
public ref class CodecsWebpSaveOptions  
class CodecsWebpSaveOptions: 
Remarks

Obtain an instance of this class by getting the CodecsWebpOptions.Save property.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.ImageProcessing.Core; 
 
public void CodecsWebpSaveOptionsExample() 
{ 
   // Saves an animated WEBP file. 
   // Stores all animation frames in a single RasterImage object. 
   string srcFile = Path.Combine(LEAD_VARS.ImagesDir, @"eye.gif"); 
   string dstFile = Path.Combine(LEAD_VARS.ImagesDir, @"eye.webp"); 
 
   // Load all the pages in the same RasterImage object  
   using (RasterCodecs codecs = new RasterCodecs()) 
   using (RasterImage image = codecs.Load(srcFile, 0, CodecsLoadByteOrder.BgrOrGray, 1, -1)) 
   { 
      using (CodecsImageInfo info = codecs.GetInformation(srcFile, true)) 
      { 
         codecs.Options.Webp.Save.AnimationWidth = info.Gif.AnimationWidth; 
         codecs.Options.Webp.Save.AnimationHeight = info.Gif.AnimationHeight; 
         codecs.Options.Webp.Save.UseAnimationBackground = info.Gif.HasAnimationBackground; 
         codecs.Options.Webp.Save.AnimationBackground = info.Gif.AnimationBackground; 
         codecs.Options.Webp.Save.UseAnimationLoop = info.Gif.HasAnimationLoop; 
         codecs.Options.Webp.Save.AnimationLoop = info.Gif.AnimationLoop; 
         codecs.Options.Webp.Save.QualityFactor = 0; // use lossless compression 
      } 
 
      // Retrieves Webp save options 
      CodecsWebpSaveOptions codecsWebpSaveOptions = codecs.Options.Webp.Save; 
      Debug.WriteLine($"AnimationWidth: {codecsWebpSaveOptions.AnimationWidth}"); 
 
      // delete the output file in case you run this code more than once 
      File.Delete(dstFile); 
      // save all the pages, appending each new page 
      codecs.Save(image, dstFile, RasterImageFormat.WebpAni, 0, 1, -1, 1, CodecsSavePageMode.Append); 
   } 
} 
 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.