I use pThumb on all my sites, and since moving some sites to MODX3, I’ve had to turn off Resizer, since it doesn’t work well with the new MODX and PHP 8.x. Image resizing using pThumb is now significantly slower. Pages with lots of images are taking a long time to load before they’re cached.
Do you know why without Resizer it is so much slower for you?
Is it that you can use the image library “Gmagick” that is not supported in phpThumb?
Otherwise (if the same image library is used), I don’t see why there would be much difference in execution time.
Unfortunately it’s not that simple. Breaking changes were made to Imagine with the change from version 0.7.1 to 1.0.0 (august 2018). This breaks the code in Reductionist (as explained in this post by sepiariver from september 2019).
Resizer
The MODX extra. Just a wrapper for Reductionist (with basically no code).
Reductionist
A Composer package that uses Imagine to create thumbnails.
Imagine
Image manipulation library that provides an API for all low level image processing libraries in PHP (GD, Imagick, Gmagick).
I looked at the code of Reductionist and unfortunately I don’t understand why the code was written the way it is. There is a lot of code that is specific to the image processing library (GD, Imagick, Gmagick) that is actually used.
What is the point of using an abstraction like Imagine, if so much code is still different for different image processing libraries?
Personally I see two ways to proceed forward.
Either officially declaring Resizer/Reductionist as discontinued, setting the repositories to read only and eventually removing Resizer from the pThumb extra.
Or trying to change Resizer/Reductionist to use the latest version of Imagine by throwing out a lot of the code in Reductionist and introducing breaking changes (like removing the ability to create watermarks).
Sepiariver made a attempt to implement the later (Reductionist repo, Resizer repo), but that experiment seems to be have been abandoned a long time ago.
Yes, the problem is that when you install the latest version of pThumb, it comes with Resizer 1.0.1-pl that uses 10-year-old code for Reductionist and the Imagine library.
You can upgrade to Resizer 1.0.2-beta. That gives you 7-year-old Imagine code that still doesn’t support WebP or PHP 8. So on a current server environment, this is not a viable replacement for phpThumb.
I’ve taken to not using any of these modx resizers because most are based on ancient code, or as the OP notes - just don’t perform well. The path of least resistance is to move your image resizing to the edge, using something like Cloudflare Images. Some of these providers have free tiers which are fine for small and medium sized sites.
@snowcreative I’ve create a new experimental version of Resizer. This version is only for MODX 3. It uses the current version of the Imagine library and should work with PHP 8. (It no longer supports the watermark filter though.)
It’s largely untested, but if you want, you can try it out and see if it indeed works faster than pThumb with the phpThumb library on your system.
At this point I’m mostly interested if there is a significant speed difference between Imagine and the default phpThumb, to see if it is worth investing more time to understand and fix the rest of the code.
Yes, that is correct.
You could also try changing to GD (resizer.graphics_library = 0) as there wasn’t special code for GD that I deleted.
I believe when Resizer was created, there were performance issues with the phpThumb library. It seems they have been fixed in the meantime.
It’s also weird that iMagick is so much slower.
All in all, with these results, I don’t think there is much point in investing more time to keep the Resizer extra up-to-date.