[xep-support] Re: Output to image

Jan Tošovský j.tosovsky at gmc.net
Wed Nov 6 23:35:35 PST 2013


Alternatively you can use:

1.       Batik rasterizer - http://xmlgraphics.apache.org/batik/tools/rasterizer.html
java -jar batik-rasterizer.jar -d output -m image/png *.svg
(converts all svg images in the folder into the output folder)

2.       PhantomJS - http://phantomjs.org/ - it contains rasterize.js script for this

phantomjs.exe rasterize.js my.svg my.png



PhantomJS uses the WebKit engine under the hood so it can support all SVG features you can display in the browser. I've recently switched to it as Batik could not process advanced mask and filters in my files.



Jan


From: xep-support-bounces at renderx.com<mailto:xep-support-bounces at renderx.com> [mailto:xep-support-bounces at renderx.com] On Behalf Of Kevin Brown
Sent: Thursday, 7 November 2013 10:14 AM
To: 'RenderX Community Support List'
Subject: [xep-support] Re: Output to image

If the SVGs are on disk ... and they contain the width/height information inside ... here's a little trick XSL .. makes a PDF that is only the SVG.

You could run all SVGs to PDF and then all PDFs to image ...

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:svg="http://www.w3.org/2000/svg"
  xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <xsl:template match="svg:svg">
    <fo:root>

      &l t;fo:layout-master-set>
        <fo:simple-page-master master-name="svgimage">
          <xsl:attribute name="page-width"><xsl:value-of select="@width"/></xsl:attribute>
          <xsl:attribute name="page-height"><xsl:value-of select="@height"/></xsl:attribute>
          <fo:region-body margin="0cm"/>
        </fo:simple-page-master>
      </fo:layout-master-set>

      <fo:page-sequence master-reference="svgimage">
        <fo:flow flow-name="xsl-region-body">
          <fo:block line-height="0">
            <fo:instream-foreign-object>
              <xsl:copy-of select="."/>
            </fo:instream-foreign-object>
          </fo:block>
        </fo:flow>
&nb sp;     </fo:page-sequence>

    </fo:root>

  </xsl:template>

</xsl:stylesheet>< /p>


!DSPAM:87,527b44159851496120170!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.renderx.com/pipermail/xep-support/attachments/20131107/8277a360/attachment-0001.html>


More information about the Xep-support mailing list