$image = new Imagick('image.png'); $image->setImageFormat('jpg'); $image->writeImage('converted_image.jpg');
$image = new Imagick('image.jpg'); $image->setImageFormat('gif'); $image->writeImage('converted_image.gif');In this example, we create a new Imagick object with the source image file 'image.jpg'. We then use the setImageFormat() method to set the format of the image to GIF. Finally, we use the writeImage() method to write the converted image to a file named 'converted_image.gif'. Package library: PHP Imagick