apache > cocoon
 
Font size:      

SVG/PNG Serializer (2.1 legacy document)

Warning
This document was copied as is from the Cocoon 2.1 documentation, but has not yet been fully reviewed or moved to its new home.

SVG/PNG Serializer

The SVG/PNG serializes an xml svg document to a png image. The serialization uses the Batik's PNGTranscoder internally.

  • Name : svg2png
  • Class: org.apache.cocoon.serialization.SVGSerializer
  • Cacheable: yes

Sitemap Configuration

A minimal sitemap configuration snippet declaring the svg2png serializer:

<map:serializers..
  <map:serializer name="svg2png"
    src="org.apache.cocoon.serialization.SVGSerializer"
    mime-type="image/png"
    logger="sitemap.serializer.svg2png"
  >
  </map:serializer>

A sitemap pipeline snippet using the svg2png serializer:

<map:match pattern="svg/*.png">
  <map:generate src="docs/samples/svg/{1}.svg"/>
  <map:serialize type="svg2png"/>
</map:match>

In the declaration section of the svg2png a number of parameters can be specified. The following snippet set the background color explicitly:

<map:serializers..
  <map:serializer name="svg2png"
    src="org.apache.cocoon.serialization.SVGSerializer"
    mime-type="image/png"
    logger="sitemap.serializer.svg2png"
  >
    <parameter name="background_color" type="color" value="#ff00ff"/>
  </map:serializer>

PNGTranscoder Parameters

General ImageTranscoder parameters are described at the SVG Serializer user documentation.

The following section presents PNGTranscoder specific parameters configurable for the PNGTranscoder.

ParameterTypeComment
force_transparent_whitebooleanIt controls whether the encoder should force the image's fully transparent pixels to be fully transparent white instead of fully transparent black. This is usefull when the encoded PNG is displayed in a browser which does not support PNG transparency and lets the image display with a white background instead of a black background.
However, note that the modified image will display differently over a white background in a viewer that supports transparency.
gammafloatControls the gamma correction of the png image; by default its value is approx 2.22.

Further Reading

Further details about PNGTranscoder, ImageTranscoder is available at Batik.

Comments

add your comments