How to use new Imagick adapter?


#1

The documentation on Image Thumbnails teases that there’s a new Imagick adapter available, but then it cuts off saying “@TODO: How to set the new adapter in config.yml”

Does anyone here know how to set the new adapter?


#2

Digging into the code a bit, it looks like use of the new adapter isn’t currently supported. Here’s what I found in Pimcore\Image. It seems the only way to use Pimcore\Image\Adapter\ImageMagick instead of Pimcore\Image\Adapter\Imagick would be to mess with the class autoloader, and I kind of doubt that’s recommended.

namespace Pimcore;

use Pimcore\Image\Adapter;

class Image
{
    /**
     * @return null|Adapter\GD|Adapter\Imagick
     *
     * @throws \Exception
     */
    public static function getInstance()
    {
        //@TODO should be configured on the container
        $adapter = self::create();

        return $adapter;
    }

    /**
     * @return null|Adapter\GD|Adapter\Imagick
     *
     * @throws \Exception
     */
    public static function create()
    {
        try {
            if (extension_loaded('imagick')) {
                return new Adapter\Imagick();
            } else {
                return new Adapter\GD();
            }
        } catch (\Exception $e) {
            Logger::crit('Unable to load image extensions: ' . $e->getMessage());
            throw $e;
        }
    }
}

#3

I would like to see that documented as well, since Mittwald, supports ImageMagick very well and Imagick only very particular.

@maff @brusch @fash


#4

tried such things:

models:
    class_overrides:
         'Pimcore\Model\DataObject\[Generic]': 'AppBundle\Model\DataObject\[Special]'
         'Pimcore\Image\Adapter\Imagick': 'Pimcore\Image\Adapter\ImageMagick'
         'Pimcore\Image\Adapter\GD': 'Pimcore\Image\Adapter\ImageMagick'
         'Pimcore\Image\Adapter': 'Pimcore\Image\Adapter\ImageMagick'

did not work.


#5

I am afraid thats currently not possible, pimcore decides the adapter based on if you have imagick installed, and thats it, there is a TODO in the code to make that configurable, but thats not implemented yet.