ImageEn, unit imageenio

TImageEnIO.SaveToFileWebP

TImageEnIO.SaveToFileWebP


Declaration

procedure SaveToFileWebP(const FileName: WideString);


Description

Saves the current image to a file in WebP format.
The method used to save WebP files is specified by ActiveWebPEngine.

To save the image losslessly, set HDP_Lossless to true. Otherwise, specify the level of compression using HDP_ImageQuality.

Note:
For ImageMagick Plug-In, use a Dictionary to specify quality options
If an internal save error is encountered Aborting will return true. Saving issues due to insufficient write permissions and disk write failures will raise an exception.
To abort while saving set Aborting to true


Examples

// Save an image to a WebP file with 80% quality
ImageEnView1.IO.Params.HDP_ImageQuality := 0.80;
ImageEnView1.IO.SaveToFileWebP( 'D:\image.webp; );

// Save an image to a lossless WebP
ImageEnView1.IO.Params.HDP_Lossless := True;
ImageEnView1.IO.SaveToFileWebP( 'D:\image.webp' );


// WebP Size Comparisons
ImageEnView1.IO.LoadFromFile( 'D:\Alpha.png' );   // Original PNG - 610KB

ImageEnView1.IO.Params.HDP_ImageQuality := 1.0;
ImageEnView1.IO.Params.HDP_Lossless     := False;
ImageEnView1.IO.SaveToFile( 'D:\image100.WebP' );  // 162KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.9;
ImageEnView1.IO.Params.HDP_Lossless     := False;
ImageEnView1.IO.SaveToFile( 'D:\image90.WebP' );   // 96KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.7;
ImageEnView1.IO.Params.HDP_Lossless     := False;
ImageEnView1.IO.SaveToFile( 'D:\image70.WebP' );   // 60KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.5;
ImageEnView1.IO.Params.HDP_Lossless     := False;
ImageEnView1.IO.SaveToFile( 'D:\image50.WebP' );   // 53KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.2;
ImageEnView1.IO.Params.HDP_Lossless     := False;
ImageEnView1.IO.SaveToFile( 'D:\image20.WebP' );   // 44KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.01;
ImageEnView1.IO.Params.HDP_Lossless     := False;
ImageEnView1.IO.SaveToFile( 'D:\image01.WebP' );   // 37KB

ImageEnView1.IO.Params.HDP_Lossless     := True;
ImageEnView1.IO.SaveToFile( 'D:\imageLossless.WebP' );  // 329KB (Lossless)


See Also

SaveToStreamWebP
LoadFromFileWebP