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

Missing support for viewBox #20

Closed
meyfa opened this issue Dec 12, 2016 · 7 comments · Fixed by #22
Closed

Missing support for viewBox #20

meyfa opened this issue Dec 12, 2016 · 7 comments · Fixed by #22
Labels
feature New feature or request

Comments

@meyfa
Copy link
Owner

meyfa commented Dec 12, 2016

No description provided.

@meyfa meyfa added enhancement Improvement to an existing feature feature New feature or request and removed enhancement Improvement to an existing feature labels Dec 12, 2016
@cyberhobo
Copy link

Are you working on this? I was just looking for it, happy to help or test.

@meyfa
Copy link
Owner Author

meyfa commented Dec 29, 2016

It's a bit hard to pin down the exact strategy for implementing this without breaking all sorts of things, but yes, I am working on it (kind of). I'll try to get this done in the next few days. If you've got any thoughts on it, I'm always happy to hear them! :)

@cyberhobo
Copy link

cyberhobo commented Dec 29, 2016 via email

@meyfa
Copy link
Owner Author

meyfa commented Dec 29, 2016

Setters and getters for arbitrary node attributes are supported since a few versions already. Methods in the form of getHeight() or setX($x) are only for convenience.

You should be able to achieve what you need similarly to this:

use JangoBrick\SVG\SVGImage;

$image = SVGImage::fromFile('./path/to/file.svg');

$doc = $image->getDocument();
$doc->setAttribute('viewBox', '0 0 200 200');

header('Content-Type: image/svg+xml');
echo $image;

@cyberhobo
Copy link

cyberhobo commented Dec 29, 2016 via email

@meyfa
Copy link
Owner Author

meyfa commented Dec 31, 2016

I've published the viewbox branch, with basic support for the viewBox attribute in rasterization. It seems to behave correctly, but additional verification would be nice. Note that preserveAspectRatio is not yet dealt with.

@cyberhobo
Copy link

I wrote a quick test and got the output viewBox I expected. (There were artifacts from rendering paths, but I'm guessing that's a rasterization challenge - I haven't played much with that yet.)

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

Successfully merging a pull request may close this issue.

2 participants