I cant find in imagine documentation https://imagine.readthedocs.org/en/latest/index.html how can i get mime type.

I just open an image like this:

$myImage = $imagine->open('/path/to/image.gif');

I have now $myImage, how can i get mime type?

Regards.

有帮助吗?

解决方案

Since you're sure you're always working with images, you can use exif_imagetype like described in the documentation by passing the same path you opened. Mixed with image_type_to_mime_type (documented here) you should be able to achieve your desired results.

$filename = '/path/to/image.gif';
$myImage = $imagine->open($filename);
$imagetype = exif_imagetype($filename);
if($imagetype) // check that you have a valid type, but most likely always the case
    $mimetype = image_type_to_mime_type($imagetype);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top