/// <summary> /// Save a bitmap as a webp file. (Requires the libwebp_x64.dll or libwebp_x86.dll) /// </summary> /// <param name="img"> The bitmap to encode. </param> /// <param name="Path"> The path to save the bitmap. </param> /// <param name="q"> The webp quality args. </param> /// <param name="collectGarbage"> A bool indicating if GC.Collect should be called after saving. </param> /// <returns> true if the bitmap was saved successfully, else false </returns> public static bool SaveWebp(Bitmap img, string path, WebPQuality q, bool collectGarbage = true) { if (!InternalSettings.WebP_Plugin_Exists || string.IsNullOrEmpty(path) || img == null) { return(false); } q = InternalSettings.WebpQuality_Default; try { Webp.Save(img, path, q); return(true); } catch (Exception e) { if (ShowExceptions) { e.ShowError(); } return(false); } finally { if (collectGarbage) { GC.Collect(); } } }
/// <summary> /// Save an image as a webp file. (Requires the libwebp_x64.dll or libwebp_x86.dll) /// </summary> /// <param name="img"> The image to encode. </param> /// <param name="filePath"> The path to save the image. </param> /// <param name="q"> The webp quality args. </param> /// <param name="collectGarbage"> A bool indicating if GC.Collect should be called after saving. </param> /// <returns> true if the image was saved successfully, else false </returns> public static bool SaveWebp(Image img, string path, WebPQuality q, bool collectGarbage = true) { return(SaveWebp((Bitmap)img, path, q, collectGarbage)); }