Drupal Association members fund grants that make connections all over the world.
Developers are not able to add image toolkit specific code to their effects. Based on the current design they can only extend a toolkit to add that code. For example, if they want to add new operations to GD toolkit, they need to extend GD toolkit. But as other modules may want to do the same, clashes can occur where multiple image toolkits exists that are derived from the GD toolkit.
To solve this we need a way to decorate toolkits instead of extend them.
Convert image toolkit operations to plugins. A few details of the implementation:
- The plugins are defined by their operation and the toolkit they are meant for. The toolkit and the operation are elements of the annotation.
- Core operations (resize, scale, etc.) are converted to plugins.
- The canonical approach to calling toolkit operations is via a chain of apply() methods (on ImageInterface, ImageToolkitInterface, and ImageToolkitOperationInterface). This means that the methods resize(), scale(), etc are removed from ImageToolkitInterface.
- For DX convenience, core methods
desaturate()are reintroduced in
Image, as specific proxies to the canonical
- To support some argument checking (arguments are now passed in a keyed array), the ImageToolkitOperationBase implemented a template design pattern that includes some default argument checking (by the base class) but also allows for argument checking by the child class.
desaturate()are transformed to plugins and then removed from
apply()methods are introduced in
- Core methods
desaturate()that were removed from
Imagein are reintroduced as proxies to the
Original report by @fietserwin
The image system has now largely been converted to a plugin based system. As co-maintainer for imagecache_actions this triggered me to start thinking about how to convert our module (that implements a set of image effects) to D8.
The image effects itself will be rather straightforward. but these effects also contain toolkit specific code. Where should I put this code?
Straight forward solution: extend from GDToolkit (and ImageMagickToolkit when available) and put our code in there. Register it as toolkit to use.
However, this has a major problem: if our module extends from GDToolkit and another module that implements image effects does so as well, we have competing toolkits that neither support the full range of image effects.