pThumb icon indicating copy to clipboard operation
pThumb copied to clipboard

php 8 - not saving to cache

Open RuthEd opened this issue 2 years ago • 7 comments

After upgrading to php 8 (modx 2.84 or 3.0 or 3.01), I'm getting the following error - the images are all showing up on the page, but the cache is empty. All was working fine on php7.4. Any ideas?

[2022-06-04 16:33:17] (ERROR @ /homepages/[account-num]/htdocs/core/components/phpthumbof/model/phpthumbof.class.php : 156) [pThumb] Resource: 1 || Image: assets/images/header-new-17.jpg Could not cache thumbnail to file at: /homepages/[account-num]/htdocs/assets/image-cache/header-new-17.c86d3627.jpg Resizer debug output: [0] => Resizer v1.0.1 [1] => Using GD [2] => Input file: assets/images/header-new-17.jpg [3] => Input options: 'f' => 'jpeg' [4] => *** Error *** Unable to open image assets/images/header-new-17.jpg

RuthEd avatar Jun 05 '22 19:06 RuthEd

I'm currently facing the same problem. Did you find a solution for this?

labr1005 avatar Oct 18 '22 06:10 labr1005

PHP 8 was also causing me problems with the Collections extra so I'm afraid I went back to PHP 7.4 for the moment. Although I manage pretty well with simple PHP snippets, my knowledge is not good enough to find the problems in other code so I expect I'll try again in a few months hoping someone cleverer than me has solved the problem meanwhile.

RuthEd avatar Oct 18 '22 07:10 RuthEd

I just noticed this problem too. Thumbnails are not being generated and cached after switching to PHP 8.0.

Is the issue mainly from Resizer and PHP 8.0?

pixelstuff avatar Feb 12 '23 19:02 pixelstuff

This is Resizer issue on PHP 8! On Modx 3.0.3, PHP 8.1 and resizer-2.0.1-dev (Laragon windows) no errors in console. But ALL output paths are directly to originals, not cached images.

On PHP 7.4 paths are correct.

valokammi avatar Aug 30 '23 13:08 valokammi

Hello, i've got the same error today and test it on to different sites. Here are the results.

Host: IONOS Germany MODX 3.0.2 pThumb 2.3.3-pl resizer 1.0.2-beta PHP: 8.1 Imagick: no GD: yes

[[!pthumb? &input=`upload/PNGRIFF838.jpg` &options=`w=519`]] > failed

Host: All-Inkl MODX 3.0.3 pThumb 2.3.3-pl resizer 1.0.2-beta PHP: 8.1 Imagick: yes GD: yes

[[!pthumb? &input=`upload/PNGRIFF838.jpg` &options=`w=519`]] > success

On IONOS is Imagick not avaible, so it use GD. If i changed to GD on the working Host it also failed.

Maybe it is a problem width GD?

jenswittmann avatar Sep 26 '23 09:09 jenswittmann

After looking deeper into that i found a solution for IONOS and GD Lib.

  1. I activate Resizer in the phpthumbof system_settings (because its modern and fast).
  2. Comment out the following in file core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gd/Imagine.php. Because a change in PHP8 (On success, this function returns a GDImage instance now; previously, a resource was returned, see https://www.php.net/manual/en/function.imagecreatefromstring.php). image
  3. Add the following in file core/components/resizer/model/vendor/sepiariver/reductionist/src/Reductionist/Reductionist.php, because on IONOS memory_limit is set on -1.
    image

Now it seems to work with pThumb, Resizer and GD ✅

The pThumb Extra uses Reductionist and Imagine under the hood. Reductionist should be work fine on PHP8, because there is only a "problem" for the memory_limit calculation when set on -1. For Imagine is a newer Version with PHP8 support ready and should be updated?

I will have a deeper look into it later ⌛

jenswittmann avatar Sep 26 '23 19:09 jenswittmann

This issue has been mentioned on MODX Community. There might be relevant details there:

https://community.modx.com/t/pthumb-resizer-and-modx-3/6366/7

modxcommunity avatar Sep 26 '23 19:09 modxcommunity