react-easy-crop icon indicating copy to clipboard operation
react-easy-crop copied to clipboard

CropArea won't fill parent when using rotated images

Open sjaakluthart opened this issue 2 years ago • 5 comments

Describe the bug

The crop area is small than it's parent when using a rotation of 90 degrees. I expect the crop area to be the same size as the parent element. I've added a codesandbox for this issue https://codesandbox.io/s/elated-ritchie-ig1bgy

sjaakluthart avatar Aug 19 '22 10:08 sjaakluthart

The image isn't rotated in the sandbox. Could you please update it t actually show the issue?

ValentinH avatar Aug 19 '22 12:08 ValentinH

I forgot to save the sandbox, it should work now.

sjaakluthart avatar Aug 19 '22 12:08 sjaakluthart

I see.

The thing is that the crop area size is also limited by the image size. The layout logic of the cropper works like this:

  • the image is displayed with scale = 1 (no zoom)
  • the image is rotated using a transform
  • the crop area size is set in order to take the maximum space between the container size and the image size.

In your example, the rotated image behaves like a "portrait" one so the only way to have the crop area filling the parent would be for the crop area to also be "portrait" (3/4) for example.

ValentinH avatar Aug 19 '22 15:08 ValentinH

@ValentinH, is there any way to get the expected output?

jorrit91 avatar Aug 25 '22 08:08 jorrit91

I don't think so.

ValentinH avatar Aug 26 '22 18:08 ValentinH

Closing as there was no answer for a while. Comment to re-open 😉

ValentinH avatar Oct 21 '22 09:10 ValentinH