apache > cocoon
 

SVG/JPEG Serializer

SVG/JPEG Serializer

The SVG/JPEG serializes an xml svg document to a jpeg image. The serialization uses the Batik's JPEGTranscoder internally.

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

Sitemap Configuration

A minimal sitemap configuration snippet declaring the svg2jpeg serializer:

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

A sitemap pipeline snippet using the svg2jpeg serializer:

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

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

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

JPEGTranscoder Parameters

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

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

Parameter

Type

Comment

quality

float

Specifies the JPEG quality as value between 0.0 and 1.0, 1.0 specifies highest quality. Usually a value of 0.9 is choosen.

Further Reading

Further details about JPEGTranscoder, ImageTranscoder is available at Batik.