Repository navigation
Speed up Imagick fill with opaque colors - #1560
Merged
olivervogel merged 1 commit intoNov 25, 2026
Merged
Conversation
Member
|
Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FillModifierfills a whole Imagick frame by rasterizing a full sizeImagickDraw::rectangle().For an opaque color every pixel is replaced anyway, so the frame can be reset to the color with
ImagickDraw::color(0, 0, Imagick::PAINT_RESET).Colors with transparency still use the rectangle, because they must blend with the existing pixels.
CPU per
fill('ff5500'), 1920x1280, median of 30 runs:Output is identical to
develop: pixel signature, alpha channel state, type, colorspace, depth and pageof every frame, frame count, and the PNG (decoded pixels + IHDR), JPEG, GIF and WebP encodings. Checked
on 238 cases (every image in
tests/resources, a new canvas, a PNG with partial alpha and grayscale JPEGand PNG, each filled with 7 colors incl. white, black, primaries and a translucent one), on ImageMagick
6.9.11-60, 6.9.12-98 and 7.1.1-43: 0 differences.
Two tests added: an opaque fill covers transparent and animated images (all frames), and a
translucent fill still blends. Both pass on
developtoo. The test suite has the same resultbefore and after (the failures that remain come from extensions missing in my environment: exif, heic).
GD:
imagefilledrectangle()is already cheap (4.6 ms at 1200x1200). Turning off alpha blending foropaque colors saves about 1 ms, so it is not part of this PR.
🤖 Generated with Claude Code