Setting to major because this is a major performance issue.
The whole idea of transformDimensions is to be able to calculate the size of an image *without* having to access it.
\Drupal\crop\Plugin\ImageEffect\CropEffect::transformDimensions() creates an image toolkit object with the *only* purpose of reading out the source again.
I'm also not sure if it's really valid to store $this->crop, as I could imagine that the same instance could be used for different images, but not sure about that.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | crop-effect-avoid-io-2868638-2.patch | 725 bytes | berdir |
Comments
Comment #2
berdirThis, basically, actually results in less code even. I think it is unlikely that this is called multiple times for the same image in the same request, so the optimization to not load multiple times probably isn't worth it but I have no numbers on that.
Comment #3
woprrr commentedHi @berdir,
This work like a charm :) ! This is important to avoid all uneeded complexity.
I have tested all usecases and works well (Image Widget Crop / Crop API manually / Focal point).
(This work perfectly into 1.x and 2.x branches).
Comment #6
woprrr commentedThat can be very informative to have more feedback about gain of performance. In all cases everything works well with that patch.