scale image width and height?

Asked by Rdtennent

Is it possible to use options to scale the width and height parameters in the <svg ...> command of the generated svg file (apart from post-editing)?

Question information

Language:
English Edit question
Status:
Solved
For:
dvisvgm Edit question
Assignee:
Martin Gieseking Edit question
Solved by:
Rdtennent
Solved:
Last query:
Last reply:
Revision history for this message
Martin Gieseking (martin-gieseking) said :
#1

You can use option --scale to scale the graphics by a given factor. As a result, the witdh and height attributes of the svg element are adjusted accordingly. Additionally, the page group element gets a transformation matrix assigned.
dvisvgm doesn't offer an option to only scale the values of the width/height attributes. This must be realized by post-processing (which is easy with XQuery for example).

Revision history for this message
Rdtennent (rdtennent) said :
#2

I can't seem to get an effect like "zooming" in a browser using --scale. But scaling the width/height attributes alone does this.
Please consider adding a new option. Using an XQuery processor seems like overkill.

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#3

Sorry, I can't reproduce this behavior. All browsers I tested (Firefox, Opera, Chrome, IE) do scale the SVG correctly, i.e. the graphic gets larger/smaller accordingly.

If you prefer using more generic tools like perl or awk, you can of course use them too -- especially for this simple task. Personally, I don't consider XQuery overkill. Too me, it's just a specialized scripting language that offers powerful operations on XML files requiring only few lines of code. Processors like XQilla are pretty compact as well.

Revision history for this message
Rdtennent (rdtennent) said :
#4

> Sorry, I can't reproduce this behavior. All browsers I tested (Firefox, Opera, Chrome, IE) do scale the SVG correctly, i.e. the graphic gets larger/smaller accordingly.

I wasn't clear. That's the kind of scaling I want to force onto the svg, before it gets to the browser.

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#5

Could you please elaborate this a bit more? I think I don't quite understand what you're trying to do. :(

Revision history for this message
Rdtennent (rdtennent) said :
#6

I want an option, say, -Z x , such that the width and height attributes of the image get multiplied by x. Then the image is initially displayed by a browser with x as the zoom factor. The viewBox and all the rest don't have to change because the image is *scaleable*.

The practical context is this: a TeX file is oriented to printing on standard paper, say letter or a4 or legal. But when converted to svg and displayed in a browser or even in inkview, the image is too small on high-resolution displays. Of course, browsers allow you to zoom, but there's no reason why the initial display has to be always too small. And, yes, the svg file can be edited or a simple script can be written to find those attributes and do the multiplication; but this would be very simple to implement in dvisvgm and could be done before compressing, saving another explicit step.

Bob T.

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#7

Thanks for the additional information. I think about adding a --zoom option to the next release.

Revision history for this message
Rdtennent (rdtennent) said :
#8

Thanks.

Bob T.

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#9

The new --zoom option is now available in dvisvgm 1.6.