Giter Site home page Giter Site logo

Missing support for viewBox about php-svg HOT 7 CLOSED

meyfa avatar meyfa commented on May 18, 2024
Missing support for viewBox

from php-svg.

Comments (7)

cyberhobo avatar cyberhobo commented on May 18, 2024

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

from php-svg.

meyfa avatar meyfa commented on May 18, 2024

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! :)

from php-svg.

cyberhobo avatar cyberhobo commented on May 18, 2024

from php-svg.

meyfa avatar meyfa commented on May 18, 2024

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;

from php-svg.

cyberhobo avatar cyberhobo commented on May 18, 2024

from php-svg.

meyfa avatar meyfa commented on May 18, 2024

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.

from php-svg.

cyberhobo avatar cyberhobo commented on May 18, 2024

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.)

from php-svg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.