pThumb Resizer and MODx 3

Is pThumb resizer compatible with MODx 3? I’m getting these kinds of error messages for every resize attempt.


[2023-02-02 18:38:46] (ERROR @ /ROOT/core/components/phpthumbof/model/phpthumbof.class.php : 156) [pThumb] Resource: 83 || Image: assets/images/page-icons/2015-hd-icon.jpg
Could not cache thumbnail to file at: /ROOT/assets/images-cache/page-icons/2015-hd-icon.da0d3d48.jpg
Resizer debug output:
    [0] => Resizer v1.0.1
    [1] => Using GD
    [2] => Input file: assets/images/page-icons/2015-hd-icon.jpg
    [3] => Input options: 
  'w' => '130',
  'h' => '130',
  'f' => 'jpeg'
    [4] => *** Error *** Unable to open image assets/images/page-icons/2015-hd-icon.jpg

pThumb should work on MODX 3. I don’t know about Resizer though.

Maybe try changing the system setting phpthumbof.use_resizer to No and see if it works then.

Turning resizer off stopped producing the previous errors, although it seems noticeably slower now on a fresh page with dozens of thumbnails. It used to take 2-3 seconds for resizer to build a page, now it is like 15 seconds for it to load if the image-cache hasn’t previously been built.

And now I’m seeing these errors over and over instead.

(ERROR @ /ROOT/core/cache/includes/elements/modx/revolution/modsnippet/142.include.cache.php : 209) PHP warning: Undefined variable $showLog
(ERROR @ /ROOT/core/vendor/james-heinrich/phpthumb/phpthumb.class.php : 1587) PHP warning: file_get_contents(/ROOT/assets/images-cache/2022//phpThumbCacheIMversion.txt): Failed to open stream: No such file or directory
(ERROR @ /ROOT/core/vendor/james-heinrich/phpthumb/phpthumb.class.php : 1514) PHP warning: file_get_contents(/ROOT/assets/images-cache/2022//phpThumbCacheIMcommandlineBase.txt): Failed to open stream: No such file or directory
(ERROR @ /ROOT/core/vendor/james-heinrich/phpthumb/phpthumb.class.php : 1492) PHP warning: file_get_contents(/ROOT/assets/images-cache/2022//phpThumbCacheIMwhichConvert.txt): Failed to open stream: No such file or directory

Which PHP version are you using? I made a note to myself a while back that Resizer doesn’t work with PHP 8 - well at least with MODX 3

Those errors kinda sound more than wrong paths than a compatibility issue to me. Make sure they exist where pthumb is trying to find them, and see if you can track down the source of that double slash.

It is PHP 8.0. That is probably the issue with Resizer as the MODx 2.8.4 site was on PHP 7.4.

The double slash looked suspicious to me too, but I have no idea what is generating them. The txt files do not exist.

The cached thumbnails seem to be there and are linked properly on the page. (Note: when Resizer was turned on the thumbnail generation would fail and the full sized image was linked).

The pthumb calls are the same as before, inside a getResources template:

[[!pthumb? &input=`[[+tv.img_1920x1080]]` &options=`&w=150&q=90`]]

In the global settings, I have the parallel cache turned on. So the image base directory is assets/images and the pThumb cache is assets/images-cache

I used to have phpThumb installed before uninstalling it and installing pThumb.

i run in a same problem today. Here is what i found for now to get it work on IONOS: php 8 - not saving to cache · Issue #72 · modxcms/pThumb · GitHub

I have pthumb 2.3.3-pl with resizer 1.0.2-beta working on multiple MODX 3.0.3 sites on cloud with php 8.1

Hi, I’m going to hook up to the topic. How to save a file to a specific place and with a specific name using: pThumb?

I don’t think pThumb is the right tool for this.
Internally pThumb uses the phpThumb library (that comes with MODX).

You can use this library directly to generate a thumbnail and save it.
Take a look at this example code from the library:

This script is used to save photos submitted by the form. I did it differently, using pThumb.

  1. Create a thumbnail for myself using pThumb (there are cool setting parameters there)
  1. I create a copy of the pThumb thumbnail file: save where I want and name it as I want
  1. I delete the pThumb thumbnail