Description
Hi there !
While inspecting my dependencies, I just noticed that intervention/image
had a new v3 version.
My project use ux-lazy-image
. I was able to upgrade intervention/image to the last version, and few problems appears.
On LazyImageExtension, the instance of ImageManager need a driver now (Driver class or an instance of driver). Could be interesting to check if we have Imagick or GD available at this moment to pass with correct driver. However, if we need to support both v2 and v3, i think we should add more adjustment:
class LazyLoadExtension extends Extension implements PrependExtensionInterface
{
public function load(array $configs, ContainerBuilder $container)
{
if (class_exists(ImageManager::class)) {
$definition = new Definition(ImageManager::class);
if (class_exists(\Imagick::class)) {
$definition->addArgument(\Intervention\Image\Drivers\Imagick\Driver::class);
} else if (class_exists(\GdImage::class)) {
$definition->addArgument(\Intervention\Image\Drivers\Gd\Driver::class);
}
$container
->setDefinition('lazy_image.image_manager', $definition)
->setPublic(false)
;
}
// ...
Then, in the BlurHash service, there is few changes in the API provided by the imageManager.
I listed following :
- make() -> read()
- pixel() -> drawPixel() (and x,y in first args)
- canvas() -> create()
- pickColor return now a ColorInterface object, that can be converted in array with $color->toArray()
- getWidth() and getHeight() -> width() and height() on Image object
After made all this changes, I ended up with a "Unable to decode input" exception 🙈
Possible solutions
As a quickfix and to avoid the issue for new user that directly install the latest version of intervention/image, we can add a conflic to that v3.
If we don't want to support both version, we can work on the BlurHash service to migrate with the new API (https://image.intervention.io/v3/introduction/upgrade)
If we wan't keep support of that version, and to avoid lot of "method_exist" in the BlurHash service, we maybe should add a InterventionV3BlurHash service and inject it in BlurHash interface when we detect such a version (don't know if it's possible to guess version in the bundle extension by the way).
WDYT ?
I can handle modifications after your feedback.