1. Go to this page and download the library: Download componenta/image-converter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
componenta / image-converter example snippets
use Componenta\Image\ImageConverterInterface;
use Psr\Http\Message\StreamInterface;
interface ImageConverterInterface
{
public function convert(string|StreamInterface $source, ?int $quality = null): ConvertedImage;
public function supports(string $mimeType): bool;
}
use Componenta\Image\ImageConversionTargetsProviderInterface;
use Componenta\Image\ImageConverterInterface;
final class ImagickWebPConverter implements ImageConverterInterface, ImageConversionTargetsProviderInterface
{
public array $conversionTargets {
get => ['webp', 'image/webp'];
}
// convert() and supports()
}