modxcms / pThumb

A better phpThumbOf
46 stars 28 forks source link

php 8 - not saving to cache #72

Open RuthEd opened 2 years ago

RuthEd commented 2 years ago

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

labr1005 commented 2 years ago

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

RuthEd commented 2 years ago

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.

pixelstuff commented 1 year ago

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?

valokammi commented 1 year ago

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.

jenswittmann commented 1 year ago

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 commented 1 year ago

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 ⌛

modxcommunity commented 1 year ago

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