I have a large SVG image (.svg file on my disk, not an element in a webpage) which has the viewBox parameter on the SVG element set to crop the image. Rather than cropping, I want to show the entire SVG image. How can I figure out what values I need to put in for height and width in order to show the full image without cropping or extra whitespace?
Related
I have an SVG (https://drive.google.com/open?id=1SBA2Xsi228agUO65FmtLwjg6Zuoq59-5) which is shifted. I have tried to change parameters such as width, height, viewBox, and transform attributes. I do not have a clear understanding of this area and it is not as simple as I estimated. I need to draw only the below part and remove the padding.
I do not want to use JS for this. Everything should be in the SVG file and I use it in the tag. The SVG file should not hard code the width and height and should scale as per the tag. It appears that the SVG file draws with left padding by default. I am trying to find the line in SVG that does it.
Well, I have a SVG with a viewbox like this
viewbox="-20.121819 -110.123123 0.237889 0.258823"
I need to render text inside, but it's not rendering, I guess the minimum font size is 1, so, is this possible without changing viewbox attribute in my SVG?
Ty in advance.
I'm using several libraries to generate SVG images in-browser, which can be bounced off the server through svgexport to generate PNGs or JPEGs at user-specified resolutions. (This works as expected.)
I'd like to offer the user the option of downloading the SVG that gets fed into the conversion, with the resolution used to set the width and height attributes. When I do that, the viewbox is not scaled to the specified width and height, but is padded so that the image occupies the original size area in the upper left.
While looking for solutions, I found images in the W3C documentation that illustrate the problem. If you open these images in Chrome and use the inspector to change the width and height properties,
ViewBox.svg will expand to fill the width and height (linked from here)
PreserveAspectRatio.svg will be padded to stay in the upper left (linked from here)
This does not appear related the presence or value of thepreserveAspectRatio property, or the nesting of svg tags. My files are rendered as padded rather than scaled in Chrome/Chromium, Firefox, Safari/WebKit, Opera, Inkscape, and Gapplin.
How do I ensure that my SVG is scaled rather than padded to fill the width and height?
The viewbox is not scaled when it's entered as viewbox rather than viewBox; svg attribute names are case sensitive.
The second link does not have a viewBox attribute, and adding a viewbox (lowercase) attribute has no effect.
I have a figure in restructured text using a scale directive as follows:
.. figure:: images/my_image.svg
:scale: 150 %
The the image is perfectly OK in the HTML output of sphinx, except that it is not scaled. (The svg image has width and height information and a viewBox)
It is strange, that in contrast to png figures, the <img> tag in the HTML file does not contain width and height attributes of the image (hm, can't sphinx determine width and height of the svg for some reason?).
What is the reason for this? Does sphinx support the :scale: directive for svg figures?
You may try setting the width. This can also be assigned a percentage of the current line width as value.
.. figure:: images/my_image.svg
:width: 100%
I tried to resize svg file to be opened in illustrator with smaller width and height(pixels or cm), I did this by changing width, height and viewBox attributes in <svg> tag, but it doesn't work at all. By search I have found that transform attribute via matrix value affects the real resizing of the figure, any ideas about ready made functions or scripts using python or librsvg to successfully scaling the svg figure, by the way I'm using inkscape to produce svg files. THANKS
You could try svg scour, that should be able to find a good viewBox to use (note spellning and uppercase 'B'). Then change only the width and height attributes to be whatever you want, and hopefully that should work.