neos-ui
neos-ui copied to clipboard
BUGFIX: fix bug with pixelSnapping on certain aspectRatios and image dimensions
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.
How can i reproduce the described issue?
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.
Hmm with your image i can reproduce the bug. And also when creating an image with the same dimensions.
same ratio as yours:
different ratio:
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)
(when pixel Snapping =1 ) there is a little gap below:
if you like we can have a call about this so we can move faster forward ^^
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.