Jako / ImagePlus

Advanced Image Custom TV in MODX Revolution
https://jako.github.io/ImagePlus/
GNU General Public License v2.0
29 stars 20 forks source link

ImagePlus cropping tool not working in specific scenarios with MODX 2.8.1 #89

Closed travisbotello closed 2 years ago

travisbotello commented 3 years ago

After upgrading MODX to 2.8.1 some of my ImagePlus TVs are no longer working as expected. The scenario is always like this:

When target width and height are set for this TV and I upload an image that is close to those targets or exactly matching those the preview thumbnail in the manager turns black and also in the frontend the output is broken.

TV targets:

Bildschirmfoto 2020-10-25 um 16 21 59

Set image:

Bildschirmfoto 2020-10-25 um 16 22 45

After cutting:

Bildschirmfoto 2020-10-25 um 16 23 33

In frontend it renders the absolute path:

<img src="/home/forge/test.website/public_html/assets/client/demo/2993x1995.png" alt=""/>

MODX error log shows the following:

[2020-10-25 16:25:36] (ERROR @ /home/forge/test.website/core/components/phpthumbof/model/phpthumbof.class.php : 156) [pThumb] Resource: 48 || Image: /home/forge/test.website/public_html/assets/client/demo/2993x1995.png
Could not cache thumbnail to file at: /home/forge/test.website/public_html/assets/image-cache/client/demo/2993x1995.6894564b.png
Resizer debug output:
    [0] => Resizer v1.0.1
    [1] => Using GD
    [2] => Input file: /home/forge/test.website/public_html/assets/client/demo/2993x1995.png
    [3] => Input options: 
  'sx' => '0',
  'sy' => '-1',
  'sw' => '2993',
  'sh' => '1994',
  'w' => '2992',
  'h' => '1994',
  'f' => 'png'
    [4] => *** Error *** A coordinate cannot be positioned outside of a bounding box (x: 0, y: -1995 given)
----------------------

I can bypass this issue by either uploading an image that is larger than the expected target (e.g. 3000x3000 in this scenario) or by cancelling the cropping tool. Imho I first saw this issue after upgrading MODX to 2.8.1.

travisbotello commented 3 years ago

This is the manager preview of exactly the same image and TV setup but uploaded and (never changed) in MODX 2.7.3 in the same installation:

Bildschirmfoto 2020-10-25 um 16 32 54

Compared to the black (broken) thumbnail in the working example the sh and sx parameters are set correctly to the exact size of the image whereas in the broken version those values seem to be out of scope. Wondering if this has something to do with 2.8.0 or 2.8.1

Jako commented 3 years ago

You 'just' have to detect, why the calculated sy value is -1. Is it saved with that value in the JSON in the tv value? I never was able to reproduce this miscalculation on my development machine. If you could create a demo configuration with that, i can fix this.

Jako commented 2 years ago

I am quite sure, that this is solved in 2.9.1.

travisbotello commented 2 years ago

I am quite sure, that this is solved in 2.9.1.

Still the same issue on Windows/Chrome with 2.9.1

MicrosoftTeams-image (3)

Jako commented 2 years ago

Maybe I am able to reproduce this. I don't know why the Image dimensions are not detected right. Have you tried that with an existing value in the TV? Or does it happen on a new resource too?

travisbotello commented 2 years ago

It is happening in both cases. See video here: https://www.dropbox.com/s/0m1g8gq8mubc2ai/image-crop-issue-modx.mp4?dl=0

Jako commented 2 years ago

Please check the fix in 2.9.2-rc1

travisbotello commented 2 years ago

Please check the fix in 2.9.2-rc1

Not working. The cropping tool now generates some dark skyscraper banner. Frontend output is also still empty.

MicrosoftTeams-image (4)

Jako commented 2 years ago

Can you send me the image that turns black by mail? It looks like the cropping sides are turned.

Jako commented 2 years ago

The skyscraper issue is fixed with rc2. The black image is maybe caused by transparency in the image.

travisbotello commented 2 years ago

Can you send me the image that turns black by mail? It looks like the cropping sides are turned.

Done that...!

Jako commented 2 years ago

This is fixed with 2.9.2

travisbotello commented 7 months ago

I was just able to reproduce this in MODX 3.0.4 with ImagePlus 2.9.4-pl in Google Chrome:

Screenshot 2024-03-19 at 14 12 00