neos-ui icon indicating copy to clipboard operation
neos-ui copied to clipboard

BUGFIX: fix bug with pixelSnapping on certain aspectRatios and image dimensions

Open patricekaufmann opened this issue 1 year ago • 4 comments

With 8.2 the pixelSnapping feature got introduced https://github.com/neos/neos-ui/pull/3065. We started using it in all our installations and I noticed a rare bug happening with specific combinations of image sizes and aspect ratio.

Since only cropArea.width is used for calculating the dimensions, it might happen that the resulting naturalCropHeight was bigger than the image itself, leading to errors when trying to save the image. I think it happened due to rounding in react-crop component.

The solution is made this way to keep ensuring correct aspect ratio values, incrementally subtracting the normalized aspect ratio values until the area is valid.

patricekaufmann avatar Jul 11 '23 16:07 patricekaufmann

How can i reproduce the described issue?

crydotsnake avatar Jul 11 '23 20:07 crydotsnake

First you would need an ImageInterace property with the following editorOptions:

editorOptions:
  crop:
    aspectRatio:
     pixelSnapping: TRUE

The issue appears when editing the image inside the inspector, so that would need to be configured aswell. Since this issue only appears on certain image dimensions and aspect ratios, I attach the following sample image which leads to an error in 2:3 aspect ratio: Sample Gradient JPG

The issue now occurs when moving the croparea on the ImageCropper without ever adjusting its size as demonstrated in the following video. It does not occur when not moving the area or resizing the area in addition to moving it, even dragging it to its maximum size.

https://github.com/neos/neos-ui/assets/41791606/4199669f-899a-4b16-bbf0-112224e1c9a9

To refer to the actual error message: the crop area has an y value of -1 because the area is larger than the actual image.

Is that of any use to you so that you are able to review / test it properly? Otherwise let me know if there is anything else I can prepare.

patricekaufmann avatar Jul 12 '23 02:07 patricekaufmann

Hmm with your image i can reproduce the bug. And also when creating an image with the same dimensions.

HugeImage

same ratio as yours: fwefwef

different ratio: ewfwef

also the editor behaves weird when trying to crop the 341 one ... (edit: its not actually 340,9 only my photo program told me that this were the dimensions after downscaling)

image

(when pixel Snapping =1 ) there is a little gap below:

image


if you like we can have a call about this so we can move faster forward ^^

mhsdesign avatar Jul 12 '23 09:07 mhsdesign

if you like we can have a call about this so we can move faster forward ^^

I reached out to @mhsdesign and we decided upon calling about this sometime next week. Until the problem is resolved, we will disable the snapping.

patricekaufmann avatar Jul 12 '23 13:07 patricekaufmann