- Issue created by @Driskell
- Merge request !19feat: Allow using faster GD getimagesize when only size is needed → (Open) created by Driskell
When using 10.3, CKEditor5 and using the upload inline image toolbar option, you can upload an extremely large, for example 50MB, GIF animation. Subsequent viewing of the page can take a long time and timeout as the editor rendering (core/modules/editor/src/Plugin/Filter/EditorFileReference) calls getWidth and getHeight - and this causes the coalesce of the images which uses a huge amount of memory and time depending on the GIF.
Drupal 10.3
CKEditor
Upload Image button
Create new node
Add a GIF image >50MB with many frames >100 frames
Attempt to view the node
It seems that getWidth and getHeight are triggering Imagick to both load the full image, loading megabytes of data, and also causing Imagick to coalesce the images. The load itself for me can take 20 seconds alone, and then the coalescing takes minutes.
GD toolkit uses getimagesize and does not load the image until the resource is asked for.
I would propose something along the lines of:
- If GD is installed - when parseFile is called - simply use GD to load the image data as this is massively optimised, taking 4ms in my case to identify the GIF width and height - compared to 20 seconds for IMagick to not have any width/height and the coalesce minutes to generate it. Store this.
- Parse the image during getResource only - so only parse it when operations take place
This will let getWidth and getHeight just use the getimagesize data from parseFile if the image isn't loaded - if it's loaded then perhaps coalesce at that point as things could have been changed
WDYT?
Active
2.0
Code