The Rise of Contactless Payments:...
In recent years, contactless payments have surged in popularity, driven...
<?php
namespace Buglinjo\LaravelWebp;
use Buglinjo\LaravelWebp\Exceptions\ImageMimeNotSupportedException;
use Buglinjo\LaravelWebp\Interfaces\WebpInterface;
use Buglinjo\LaravelWebp\Traits\WebpTrait;
use Illuminate\Support\Facades\File;
class PhpGD implements WebpInterface
{
use WebpTrait;
/**
* @param string $outputPath
* @param int|null $quality
* @return bool
* @throws ImageMimeNotSupportedException
*/
public function save(string $outputPath, int $quality = null): bool
{
$quality = $quality ?? $this->quality;
$path = $this->image->path();
$info = getimagesize($path);
$isAlpha = false;
switch ($info['mime']) {
case 'image/jpeg':
$image = imagecreatefromjpeg($path);
break;
case 'image/gif':
$isAlpha = true;
$image = imagecreatefromgif($path);
break;
case 'image/png':
$isAlpha = true;
$image = imagecreatefrompng($path);
break;
default:
throw new ImageMimeNotSupportedException('Image mime type' . $info['mime'] . 'is not supported.');
}
if ($isAlpha) {
imagepalettetotruecolor($image);
imagealphablending($image, true);
imagesavealpha($image, true);
}
imagewebp($image, $outputPath, $quality);
return File::exists($outputPath);
}
}
Blog Section
Dive into our blog to explore the cutting-edge trends in digital payments and NFC technology. Stay updated on the innovations that are revolutionizing transactions, boosting security, and making payments quicker and more convenient. Learn how these advancements are shaping the future of financial interactions and driving the global transition towards a cashless world.
In recent years, contactless payments have surged in popularity, driven...
As digital transactions proliferate, ensuring robust payment security is more critical than ever. Two foundational...
Digital wallets have fundamentally transformed how we manage money, offering a streamlined, secure, and highly...