aaP_thomas_marcelino imagick is similar to GD ,
Here examples converting
Convert AVIF to JPEG
<?php
$inputPath = 'image.avif';
$outputPath = 'image_converted.jpg';
try {
$image = new Imagick($inputPath);
$image->setImageFormat('jpeg');
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(85); // Adjust quality as needed
$image->writeImage($outputPath);
echo "Converted AVIF to JPEG successfully!";
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
Convert JPEG to AVIF
<?php
$inputPath = 'image.jpg';
$outputPath = 'image_converted.avif';
try {
$image = new Imagick($inputPath);
$image->setImageFormat('avif');
$image->setOption('avif:quality', '50'); // AVIF-specific quality
$image->writeImage($outputPath);
echo "Converted JPEG to AVIF successfully!";
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
Using imagick extension, PHP itself does not need to be compiled with AVIF support.
What matters is whether your ImageMagick installation supports AVIF, and that your Imagick PHP extension is linked to that ImageMagick.