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

Cropping not scaled properly for svg images with transparent background. #532

Open
artdev14 opened this issue Mar 6, 2023 · 0 comments
Open

Comments

@artdev14
Copy link

artdev14 commented Mar 6, 2023

Hello,

I recently tried to crop images of various types(png, jpeg, svg) using react-image-crop and was able to sucessfully do it for jpeg and png types. For svg type though, I'm not able to get the image to scale down properly.
Note: My requirement needs a restricted container for cropping and viewing the preview image.
Attaching the code sandbox that was forked to test it :
https://codesandbox.io/s/react-image-crop-demo-with-react-hooks-forked-v0h7lq?file=/src/canvasPreview.ts

In the code above, the scaling method for canvas is a little different, it scales based in the objectFit: 'contain' height and width.
Sample svg file:
logo

Cropped image example:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant