imagecache
imagecache copied to clipboard
Unable to load mimetype within cache function
If I try to get the mime of the image within the cache function (code below) I get the following error:
"call_user_func_array() expects parameter 1 to be a valid callback, class 'Intervention\Image\ImageManager' does not have a method 'mime'"
// pass calls to image cache
$img = Image::cache(function($image) use ($imageUrl, $width, $height) {
$mime = $image->mime();
if (!empty($width) && !empty($height)) {
$image->make($imageUrl)->fit($width, $height)->encode();
} else {
$image->make($imageUrl)->encode();
}
},525600);
It works fine if I use Image:: within the function, but then I'm loading the image again which defeats the purpose of the cache.
I want to be able to detect the mimetype and change the encoding if it's (For example) a bmp or tiff, but leave all other images in the same type (eg png)