-
Notifications
You must be signed in to change notification settings - Fork 0
berry.utils.ImageHelper
Nikos Siatras edited this page Jan 6, 2024
·
5 revisions
public function ConvertImageToWebP(string $source, int $quality = 100, bool $removeOld = false): string
This function converts .jpg, .png and .gif format images into .webp
- $source is the the source image path to convert
- $quality ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file)
- $removeOld set to true if you want to delete the original file
The following example converts a .png file to .webp
require_once(__DIR__ . "/berry/utils.php"); // Include berry utils package
$imageHelper = new ImageHelper();
$originalImagePath = "myPhoto.png";
$newWebPPath = $imageHelper->ConvertImageToWebP($originalImagePath,80,false);
print $newWebPPath;