Open JohnCido opened 2 years ago
Indeed, something is wrong with the sizes computation. First thing I noticed is that naturalWidth
/naturalHeight
doesn't exist for SVGs and we are using this to measure to media size here:
https://github.com/ValentinH/react-easy-crop/blob/4e31ef20a95f3e759aedc57e70788d778067eb52/src/Cropper.tsx#L245-L246
I guess we should use width/height
in that case but we need to check if something else needs to be adjusted.
Cropping works with some other SVGs, for example this image https://user-images.githubusercontent.com/1442690/182855138-e84d1916-8a19-4152-89a8-4c9074f54dfd.svg
Could it be that the difference is that the original svg has width="100%" height="100%" viewBox="0 0 3200 3200"
and my example has width="640" height="480" viewBox="0 0 640 480"
?
I am facing the same issue here. Is there some workaround?
Describe the bug When trying to crop an SVG file, the final output cropped area is wrong. So any code that relies on this output will generate wrong image output.
To Reproduce Steps to reproduce the behavior:
Expected behavior Crop the exact area that the user has defined using the cropper.