This program starts a simple HTTP server on port 8282 (by default) that will accept requests to convert SVG files to bitmap formats (PNG and JPEG are currently supported).
Important: Because the SVG image file standard allows for external references to be made to image files and scripts etc., it is very important that you execute the JVM under a security policy that disallows linking to remote or local data that should not be exposed. The included security.policy file implements a basic security policy that may be sufficient, however it is not guaranteed.
All of the downloads are available from the SourceForge download page.
The software was developed using Java 1.5, and as such will not build or run under a Java 1.4 JVM. Removing the generics should enable it to run however, if you're so inclined.
BatikServer depends on two external packages that must be installed either in your Java ext lib directory or in your CLASSPATH:
Batik handles rasterizing of the SVG files. Extract their binary and place 'batik.jar' in your classpath (it's just a manifest referencing the other .jar's and lib/ directory; you can't move it without those other files)
Simple provides a framework for HTTP serving and request handling. This may be replaced by custom code in the future. Download their package and place the jar file in your classpath.
The Ant build file expects the Batik in ext/batik.jar and Simple in ext/simple.jar for compilation. At runtime, modification of the security policy and/or classpath may be required.
Currently there aren't any support scripts included in the distribution. For a permanent installation, some though should be given to creating an appropriate init script to start the server. There also isn't a config file or command line argument parser yet, so it's just a matter of starting the JVM.
I haven't been able to work out how to make everything work when it's loaded in a jar either (it seems the dynamic class loading that occurs in Simple to start the service fails to find the class even though it is obviously included in the jar and available for static instantiation), suggestions appreciated.
For now, initiate the server with the following command, in the same directory as the class file root. Ensure that your CLASSPATH variable includes the Batik and Simple libraries as well as '.'.
$ java -Djava.security.manager -Djava.security.policy=../security.policy -server \
The server will then be listening on 0.0.0.0:8282 for HTTP connections.
Currently no client library is provided. The client implementation is quite trivial and can be done with minimal effort in most modern languages. The API consists of a number of HTTP URL parameters to control output, and an HTTP 'PUT' request to send the source SVG file.
URLs take the form of http://hostname:8282/format where format is a string defined by the output image format you would like to receive.
|http://hostname:8282/png||produces PNG output|
|http://hostname:8282/jpeg||produces JPEG output|
The following parameters are available for any image type:
|width:int||The maximum width of the output image|
|height:int||The maximum height of the output image|
|If one of these parameters is provided, the other must also be provided (the lone parameter will be ignored otherwise) and give the bounding box that the resized output must fit within. Aspect ratio is preserved and output size is adjusted so that this occurs.|
|max_width:int||The absolute maximum width of the output image|
|max_height:int||The absolute maximum height of the output image|
|These exist within the object to control the absolute maximum the program is willing to create. However, they have not yet been hidden from public view, allowing their use here.|
|bgcolor:string||The background colour for transparency in the image; will be flattened for formats that don't support transparency. In format ffffff where the first 2 hexadecimal digits represent red, the second 2 green and the last 2 blue.|
|white_trans:boolean||Force the transparent background to be white. This is provided by Batik, I'm not exactly sure how it interacts with bgcolour.|
|indexed:int||Create an indexed output file? If non-zero, sets the number of bits to use for the colour (1,2,4,8)|
|quality:float||The JPEG quality factor. Between 0 and 1. 1 indicates 100% quality.|