Skip to content

Remove discarded flatten in Imagick fillTransparentAreas - #1561

Merged
olivervogel merged 1 commit into
Intervention:developfrom
javiermarinros:perf/imagick-fill-transparent-areas
Nov 25, 2026
Merged

olivervogel merged 1 commit into
Intervention:developfrom
javiermarinros:perf/imagick-fill-transparent-areas

Conversation

@javiermarinros

Copy link
Copy Markdown
Contributor

a412c31 passes the result of mergeImageLayers() to $frame->setNative(), but the frame comes from
Core::current(), which wraps the core Imagick object in a new Frame on each iteration.
setNative() only replaces the native object of that temporary Frame, so the flattened image never
reaches the core.

setImageBackgroundColor() + ALPHACHANNEL_REMOVE already give the result. The flatten is a full
copy of the image for nothing. fillTransparentAreas() on a 1200x1200 canvas, median of 30 runs:
29.3 → 12.1 ms (IM 7.1.1-43), 16.1 → 5.6 ms (IM 6.9.11-60).

Output is identical with and without the line (pixel signature, alpha, type, colorspace, page, frame
count and PNG/JPEG/GIF/WebP encodings) on 33 images: every image in tests/resources, a new canvas, a PNG
with partial alpha and a 3 frame GIF with page offsets, on IM 6.9.11-60, 6.9.12-98 and 7.1.1-43.

Adds FillTransparentAreasModifierTest for Imagick (there was none): transparent pixels get the color,
and an animation keeps its frame count.

🤖 Generated with Claude Code

@olivervogel

Copy link
Copy Markdown
Member

Thanks.

@olivervogel
olivervogel merged commit 01009ae into Intervention:develop Nov 25, 2026
8 checks passed
olivervogel pushed a commit that referenced this pull request Nov 25, 2026
Co-authored-by: javimarinros <contacto@ideatic.net>
@javiermarinros
javiermarinros deleted the perf/imagick-fill-transparent-areas branch November 25, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants