Fwd: [cairo] redesigning the arguments for svg2png

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [cairo] redesigning the arguments for svg2png

MenTaLguY
Just FYI in case you had anything to add..

----- Forwarded message from Jason Dorje Short <[hidden email]>
-----
    Date: Wed, 29 Jun 2005 21:37:27 -0400
    From: Jason Dorje Short <[hidden email]>
Reply-To: Jason Dorje Short <[hidden email]>
 Subject: [cairo] redesigning the arguments for svg2png
      To: "Cairo Mail List (E-mail)" <[hidden email]>

Current arguments for svg2png:

  -w $WIDTH
  -h $HEIGHT
  -s $SCALE
  -x, --flipx
  -y, --flipy
  input.svg and output.png are taken directly as parameters

This is all explained in `man svg2png`.  The problem is it's
incomplete.

----------

For instance if you give -w and -h svg2png makes an image with the
given
$WIDTH and $HEIGHT and puts the SVG file inside it with preserved
aspect
ratio.  Thus there is no distortion and there is padding.

One thing I need to do is to change the aspect ratio.  I want to
give a
width and height and have the SVG "stretch" to take up this whole
area.
 Thus the xscale and yscale are different.  Thus there is distortion
and
there's no padding.  This is what rsvg, sodipodi, and inkscape
command-line renderers do.

A third thing one would want to do is preserve the aspect ratio but
without any padding.  Thus the $WIDTH and $HEIGHT provide the max
dimensions, just like svg2png does now, but without any padding.
Thus
there is no distortion and there is no padding.  IIRC this is what
the
librsvg rsvg_pixbuf_from_file_at_max_size function does (which I've
found very useful in the past).

Yet another thing you might want to do is specify the xscale and
yscale
independently.  I can't recall ever needing to do this, but rsvg
allows it.

Finally, one might wish to specify things in DPI.  If the SVG image
is
given in real-world dimensions (e.g., inches) giving a DPI to render
at
will allow you to make the PNG image show up at the right size when
rendered at that DPI (to a monitor or a printer).  Aspect ratio is
preserved; this is just a (possibly) convenient way of setting the
--scale.  Inkscape provides a -d $DPI parameter allowing this.  Note
that this will not work with all SVG files.

----------

Of course svg2png should be able to do all of the above tasks.  It
would
also be nice to keep command-line compatibility with rsvg, inkscape,
sodipodi.  The trick is to do all this without having confusingly
many
options or giving unexpected default behavior.

Thus I suggest:

  --width=$WIDTH (-w)
  --height=$HEIGHT (-h)
  --xscale=$X_SCALE (-x)
  --yscale=$Y_SCALE (-y)
  --flipx (-X maybe?)
  --flipy (-Y maybe?)
  --scale=$SCALE (-s)
  --dpi=$DPI (-d)
  --pad [1]
  --stretch

You may pad or stretch or neither but not both.  The default should
be
to do neither (same as rsvg, inkscape, and sodipodi), this changes
the
current behavior which is to pad.  (--pad and --stretch were
suggested
by Carl.)

Supporting -d will require new functions to libsvg and libsvg-cairo
to
set the DPI.

-x and -y are changed from flipx and flipy to xscale and yscale.
This
matches the rsvg args (they call it --x-zoom, --y-zoom).

In case of conflicting options (--width and --xscale both given) the
one
higher up in the list is given priority (this is obviously arbitrary
and
can be tweaked a bit).  Care should be taken to give a sensible
output
no matter what combination of args are given (rsvg is pretty bad at
this).

----------

For full compatibility with inkscape and rsvg it would be necessary
to
add more "long argument" aliases.  This would be convenient but
would
also add clutter to the interface.

Inkscape also has some additional parameters that might be useful,
either for new features or compatibility.  See -a, -f, -e, -i, -j,
-t,
-b, -y from `man inkscape`.  I don't understand all of these but
some of
them are probably desirable.

In a related note xsvg should probably support a similar set of
options.
 Seems there could be a lot of overlap here.

-jason
_______________________________________________
cairo mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/cairo

----- End forwarded message -----





-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. <a href="http://ads.osdn.com/?ad_idt77&alloc_id492&op=click">http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [cairo] redesigning the arguments for svg2png

Nicu Buculei (OCAL)
[hidden email] wrote:
>
> You may pad or stretch or neither but not both.  The default should
> be
> to do neither (same as rsvg, inkscape, and sodipodi), this changes
> the
> current behavior which is to pad.  (--pad and --stretch were
> suggested
> by Carl.)

After using Inkscape I would argue for the original svg2png padding
behavior: we have great pain in generating PNG thumbnails with Inkscape
for openclipart.org, ImageMagik trickery should be used to obtain usable
thumbnails.

Can we have --pad option in Inkscape too?

--
nicu


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [cairo] redesigning the arguments for svg2png

Peter Moulder
I think the default (if width and/or height are specified but no other
command-line options are given) should be as the SVG spec says in
http://www.w3.org/TR/SVG11/coords.html

That is, the width/height given on the command-line override the
value of the width/height attribute on the outermost <svg> element;
whether scaling occurs is determined by whether or not that <svg>
element has a viewBox attribute.

Following the standard tends to increase the predictability across
different renderers.

Of course, there may be other command-line arguments that override what
the document requests.

pjrm.


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel