Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect corp area output when the input is SVG #381

Open
JohnCido opened this issue May 7, 2022 · 2 comments
Open

Incorrect corp area output when the input is SVG #381

JohnCido opened this issue May 7, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@JohnCido
Copy link

JohnCido commented May 7, 2022

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:

  1. Open this sandbox
  2. Download this image
    crop test file
  3. Open this file in the sandbox
  4. Crop it and see the output

Expected behavior
Crop the exact area that the user has defined using the cropper.

@ValentinH ValentinH added the bug Something isn't working label May 9, 2022
@ValentinH
Copy link
Owner

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:

const naturalWidth = this.imageRef?.naturalWidth || this.videoRef?.videoWidth || 0
const naturalHeight = this.imageRef?.naturalHeight || this.videoRef?.videoHeight || 0

I guess we should use width/height in that case but we need to check if something else needs to be adjusted.

@raed667
Copy link
Contributor

raed667 commented Aug 4, 2022

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" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants