Follow-up to #2073759: Convert toolkit operations to plugins and for now postponed on that issue until it gets committed. Part of #2105863: [meta] Images, toolkits and operations.

Problem/Motivation

Image effects call the ImageInterface::apply method to perform the actual and toolkit dependent image manipulation. The image object forwards the apply method to the toolkit which forwards it to the appropriate image toolkit operation. This call chain separates image effects from image toolkit operations, yet they are actually strongly related. Each image effect in core has its accompanying image toolkit operation in the GD toolkit that does almost all the work, including calculations and logic that can directly be linked to the options on the image effects forms. This is not necessary, nor logical.

Examples:
- The crop operation accepts that either width or height may be empty and then decides that the aspect ration should be kept to compute the missing parameter as such.
- The scale operation has a boolean upscale parameter, to not perform the resize if that would mean upscaling the image.
- The scale and crop image effect has its own scale_and_crop operation, whereas it could just use the scale and crop operations.

As (the now closed) issue #2108307: Provide an abstract layer for image operations geometry pointed out, this leads to duplication of calculations and other logic that should better be put on a higher level.

Proposed resolution

Make the image toolkit operations dumber:
- they should perform only 1 basic image manipulation
- they should not call each other.
- they should not be to smart about missing parameters.
- they should more mimic the typical operations an actual image processing class offers (like GD or the Imagick class). Thus a resize should get the actual new length AND width, not just.
- they should preferably not do difficult calculations.

Make the image effects smarter:
- they should do the calculations themselves, especially those that are based on checkboxes and such that are offered on the UI of the image effects.
-they should be composed of more basic image manipulations.

Actual changes foreseen:
Operations:
- The scale operation will be removed.
- The scale_and_crop operation will be removed.
- The crop operation will require all 4 integer parameters.

Image effects:
- Crop should calculate the exact rectangle to crop to in the effect.
- Scale should do the aspect ratio based calculations itself, as well as the upscale check, and then call the resize operation.
- ScaleAndCrop should call the resize and crop operations itself.
- ...

Remaining tasks

- Wait for the main issue to get in.
- Find out how far we can go, considering that some calculations cannot be done by the in contrib to be dveloped ImageMagick toolkit, because the actual width and height may not be known (image (auto/random)rotate).
- Refactor the operations and the effects.

API changes

The operations provided by a toolkit are not seen as a real API, nor are their parameter definitions. So no API changes, though core and contrib effects and contrib toolkits may have to be adapted. So this should not be done too late in the beta stage.

User interface changes

None.

Comments

fietserwin’s picture

Issue summary: View changes
fietserwin’s picture

Issue summary: View changes
mgifford’s picture

Status: Postponed » Active

Seems like it is committed.

andypost’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Active » Postponed

Looks more like 9.x material

joelpittet’s picture

Status: Postponed » Active

This may be 9.0.x material, but let's unpostpone it and let someone decide who is working on this.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

smustgrave’s picture

wanted to bump this 1 more time.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.