Search code examples
laravelimagick

How to get number of images using driver Imagick on laravel 5


I used to get number of images from a file (.tiff or .tif) using Imagick

$document = new Imagick();
$document->readImage($path);
$pages = $document->getNumberImages();

Now that I use laravel to do my projects I am not being able to use the same method in the controller. I had to install the driver intervention Image and changed the driver to imagick. Anybody knows what should be the command to get the number of images? I have been looking everywhere and no luck.


Solution

  • The getCore function will let you access the underlying Imagick/GD instance.

    $img = Image::make('public/foo.jpg');
    $imagick = $img->getCore();
    $imagick->getNumberImages();