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

Svg is cropped when it is loaded via data url with FromImage or setSrc #6709

Closed
TFTomSun opened this issue Nov 27, 2020 · 4 comments
Closed

Comments

@TFTomSun
Copy link

v4.2.0
here is a fiddle that demonstrates the problem.
https://jsfiddle.net/tftomsun/gaojy6t4/85/

The canvas.drawImage(...) function works well (see fiddle). Is there a way in fabric to create an image object that is based on this function?

@asturur
Copy link
Member

asturur commented Nov 29, 2020

Your svg is missing width and height and for that reason won't reander in fabric most of the time.
https://jsfiddle.net/j7kqxo19/
Try to add non percentage width and height to the svg and it will work ok.

@asturur asturur closed this as completed Nov 29, 2020
@TFTomSun
Copy link
Author

TFTomSun commented Nov 30, 2020

@asturur thanks for the hint. I would appreciate if you could answer my question.

If possible, I would like to rely on the canvas.drawImage(...) function when using SVGs together with fabricjs, because I am afraid, that I will run into more issues using the fabricjs way of drawing SVGs. Does fabricjs somehow support that?

@asturur
Copy link
Member

asturur commented Nov 30, 2020

The object that uses drawImage at its core is fabric.Image, but your svg has to have a width and height attribute

@TFTomSun
Copy link
Author

TFTomSun commented Nov 28, 2021

@asturur Is there a workaround to pass the desired size into fabric.js? Background: I'm dealing with external images (so I can't modify them), but I know in which size I want to render them.
I saw that the topic was already discussed in this issue: #5512 .. but it seems that it never got really resolved. Having a possibility to specify / pass the render size in fabric js for svgs without size info would be sufficient from my point of view.

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

2 participants