// Create new Imagick object $image = new Imagick('image.jpg'); // Get image format $format = $image->getImageFormat(); // Output format echo $format;
// Create new Imagick object $image = new Imagick(); // Read image from URL $image->readImage('https://example.com/image.jpg'); // Get image format $format = $image->getImageFormat(); // Output format echo $format;In this example, we create a new `Imagick` object and use the `readImage` method to retrieve an image from a URL. We then use the `getImageFormat` method to retrieve the format of the image. Finally, we output the format using `echo`. The `getImageFormat` method is part of the `Imagick` class, which is part of the PHP `imagick` package.