http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Overview
FAQ
Demo
License
Download
Install

Viewer
Rasterizer
SVG Applet
Generator

Who we are
Status
CVS Repository
Mail Archive
Bug Database

Glossary
Regression tool
API (Javadoc)



Introduction

Batik SVG Rasterizer

This page describes the features of the SVG Rasterizer utility that comes with the Batik distribution. It discusses the following:

The SVG Rasterizer is a utility that can convert SVG files to a raster format. The tool can convert individual files or sets of files, making it easy to convert entire directories of SVG files. It can convert to various raster image formats and the two supported by default are JPEG and PNG.


Downloading the rasterizer

Refer to the install page and the download area to find out what to download and how to download it. Remember that you can get either the developer distribution or the binary distribution.


Rasterizing one or several SVG files

The method for starting the rasterizer depends on the distribution of Batik that you chose to download. The following describes how to start the viewer for each distribution.

Using the binary distribution

If you downloaded the binary distribution of Batik, you should have gotten a file called batik-1.0beta.zip, and, after expanding that file, a JAR (Java ARchive) file called batik-rasterizer.jar. To start the rasterizer, open a console, go to the directory where you expanded the distribution (and where batik-rasterizer.jar is located) and simply type the following at the command prompt :

java -jar batik-rasterizer.jar [@files]

For example, if you type:

java -jar batik-rasterizer.jar samples/batikFX.svg

you will see the following printout:

Converting file:samples/batikFX.svg to ./samples/batikFX.png

Once the conversion is complete, you will find a batikFX.png file in the samples directory

You can pass options to the command line:

java -jar batik-rasterizer.jar [-d <directory>] [-m <mimeType>] [@files]

Where:

  • -d <directory> lets you select the directory where the raster files will be generated.
  • -m <mimeType> lets you select the mime type corresponding to the desired raster format for the generated images. Currently, the tool supports image/jpg and image/png. The default value is image/png

For example:

  • java -jar batik-rasterizer.jar -d myDir -m image/jpg samples\*.svg will generate JPEG images for all the SVG files found in the samples directory.

Using the developer distribution

If you downloaded the developer distribution of Batik, you got a zip or tar file that expanded into an xml-batik directory. In that directory, you can find build scripts for the platform you are running on. For example, there is a build.bat script for users of the Windows platform and there is a build.sh script for UNIX users.

To start the rasterizer you should:

  • Make sure the xml-batik directory is in your PATH environment variable
  • Make sure the ANT_HOME environment variable is set to the xml-batik directory
  • Open a command line window and go to the xml-batik directory where the Batik distribution was expanded
  • At the command prompt, type: build svgrasterizer. This will printout a help message for the rasterizer

You can pass options to the rasterizer as follows:

build svgrasterizer -Dargs="[-d <directory>] [-m <mimeType>] [@files]"

Refer to "Using the binary distribution" for an explanation of these options




Copyright © 2000 The Apache Software Foundation. All Rights Reserved.