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

crop toDataURL('image/svg+xml'); #217

Closed
chitgoks opened this issue Feb 7, 2017 · 6 comments
Closed

crop toDataURL('image/svg+xml'); #217

chitgoks opened this issue Feb 7, 2017 · 6 comments

Comments

@chitgoks
Copy link

chitgoks commented Feb 7, 2017

hi. while ive read posts on how to crop canvas, its output is base 64 png. and yes, not everyone has access to the server so doing the trimming client side would definitely be helpful.

would like to request to have a crop for base 64 svg. svg is still best for output because it is vector.

@chitgoks
Copy link
Author

bump. this is a very useful feature. ^_^

i hope this feature gets some interest

@tsafs
Copy link

tsafs commented Dec 11, 2020

Three years in and not even a reply. Bump

@vipertecpro
Copy link

Three years in and not even a reply. Bump

Alright this made me emotional and want to close this issue once and for all . Will be back with solution. happy Coding.

@szimek
Copy link
Owner

szimek commented Dec 11, 2020

PRs are welcome, though if this cropping code could be implemented as a separate library or as a separate function that can doesn't have to imported if it's not used, that would be preferable to avoid bloating this library with features few people need.

Also, I'm not really maintaining this library anymore. I'll try to clean up a few things soon and update the README file with information that I'm looking for a maintainer.

@tsafs
Copy link

tsafs commented Dec 15, 2020

I am sorry that I sounded offensive. I did not intend to offend anyone. Thank you for this package, I am happily using it. What I do not like on my search for specific answers is browsing through old and open tickets that did not receive any response, so perhaps I overlooked szimeks apparent response, that he took it up as an enhancement. Again, thank you for for this package.

To anyone desperately looking up ways for cropping SVG, I found out about multiple solutions.

  1. I got lucky, because I am using those signatures in fabric.js, where you can import SVG in a way that it trims the white-space automatically. See this code snippet:
fabric.loadSVGFromURL(svgFilePath, () => {
  // these are your signature path elements grouped together 
    var loadedObjects = new fabric.Group(group);
  },
  function (item, object) {
    object.set("id", item.getAttribute("id"));
    group.push(object);
  }
);

2, You can modify the viewBox property in your SVG xml code to only show the signature.
3. Otherwise, if the background is blank, you could simply omit trimming any whitespace and work with the full vector-"image" of your signature. In another problem, where I include the SVG in a PDF-file, I went this way.

@UziTech
Copy link
Collaborator

UziTech commented Jun 19, 2021

see #49 (comment)

@UziTech UziTech closed this as completed Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants