[wp-trac] [WordPress Trac] #40415: Imagick resize filter hook
WordPress Trac
noreply at wordpress.org
Sun May 25 14:07:02 UTC 2025
#40415: Imagick resize filter hook
-------------------------------------------------+-------------------------
Reporter: virgodesign | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Media | Version: 4.7.3
Severity: normal | Resolution:
Keywords: has-patch has-test-info dev- | Focuses:
feedback |
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: has-patch needs-testing reporter-feedback => has-patch has-
test-info dev-feedback
Comment:
== Test Report
=== Description
✅ This report validates that the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-
develop/pull/8836.diff
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
* Imagick Resize Filter Demo 1.0.0
* Test Reports 1.2.0
=== Testing instructions
1. I'm providing [https://raw.githubusercontent.com/SirLouen/imagick-
resize-filter-demo/refs/tags/1.0.0/imagick-resize-filter-demo.php the
following plugin] that showcases the functionality of the report.
2. Add an image to the library (try to use a big sized image to better see
more details). Take note of the image ID
3. Go to Imagick Resize
4. Use the image ID of the picture you uploaded
5. Check the results.
- The Plugin Testing Use Case tests both the use of the newly public
function and the filter, to showcase results.
=== Actual Results
1. ✅ Issue resolved with patch.
=== Additional Notes
- The tested patch is based on the
[https://core.trac.wordpress.org/attachment/ticket/40415/40415.3.diff last
provided patch] (adding public to `thumbnail_image` method). After
several visual tests with my plugin provided, I've found that the proposal
by @losangelos is the most solid among all, and this is the one that I
have integrated, the best performance in terms of crispness, sometimes
size and not a coincidence that @adamsilverstein introduced the
`INTERLACE_PLANE` idea in the last patch of Imagick processing [57607],
which was part of this patch.
- Based on the [https://core.trac.wordpress.org/ticket/40415#comment:33
idea provided previously], the problem here is that the `resize` function,
is not only a "resizer function", but it's actually the function that
`resize_and_crop`. In fact, the function per se is not even resizing nor
cropping but calling one or the other accordingly. The actual resizer
function is `thumbnail_image`, which happens to be, as the description
says, the reimplementation of Imagick's `thumbnailImage`; hence it's fair
to have it public as it's a much more specific need of resizing. Yes, we
can actually resize with `resize` also, but for all the reasons given, we
have two options
1. Passing onwards this filter as a parameter, from `resize` to
`thumbnail_image` and to preserve the optionality of the parameter (mainly
for backward compatibility) in both methods.
2. Setting `thumbnail_image` as public.
- Whatever of these two options are chosen, aligns with the concept of
filter selection (specially given that there are no practical cases of
using such filter) without having to do the trick of setting and unsetting
the filter on `resize` function call, which seriously dirty. For this
purpose, I created the attached plugin that showcases this `use-case`
- I agree with some previous comments, the whole system as-is currently,
is convoluted. It requires a refactor, the problem is that it will
seriously affect things from a backwards compatibility perspective. For
now, this patch solves the current situation without committing into such
required refactor, and given it was proposed several versions away, I
believe it's mostly ready to get into 6.9
- **Conclusion**: With the current state of the patch, we have the option
to: A) Set a global filter, to perma-use a filter that adapts to our
preferences (i.e. Media Gallery processing). B) We have more extensibility
without compromising backwards compatibility, geared towards plugins,
without having to set and unset the filter every time `resize` method is
called, thanks to the public method upgrade to `thumbnail_image`,
providing more usefulness to the entire image filtering logic.
=== Supplemental Artifacts
Link to the plugin: https://github.com/SirLouen/imagick-resize-filter-
demo/
Results:
[[Image(https://i.imgur.com/fDBYbbq.jpeg)]]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40415#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list