4

I am trying to use the Batik library source, I only want to use the transcoder to convert SVG files to PNG or JPEG only. The distribution version of the Batik Rasterizer is about 55k but when I export the jar file its 7 megs. Can I just use the transcoder and not all the jars in the library? I am loading the jar files in Coldfusion. would it make more sense to just use the distribution version?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jesse
  • 785
  • 2
  • 9
  • 29
  • 2
    What is the reason for concern about jar size? Because you do need more than just the transcoder, though probably not all of the jars. This is a slighted outdated [dependency graph](http://xmlgraphics.apache.org/batik/install.html#dependencyGraph). Also, are you replacing the scaled down version of Batik that ships with CF or just using the JavaLoader? – Leigh Jan 21 '12 at 03:04
  • Sorry for the late response I wanted to simply use the library to convert the SVG files to jpg on the server I saw a tutorial on how to incorporate SVG conversion on A CF server. I didn't want to load any jar files unless they were required for converting the SVG file. I actually installed the jar files directly on the server and tried javaloader also. – Jesse May 24 '12 at 17:56
  • 1
    Okay, then it is not really a size consideration. Honestly, it may be more work than it is worth. Ultimately, the library needs what it needs to work .. That might be five jars or fifty. But it is usually better to have too many, than too few. The dependencies will vary depending on what actions are performed. I am not aware of a comprehensive dependency list. (The closest I have seen is the link above.) For your purposes, you could probably omit obvious ones like `squiggle`, `swing`, `gui`, etectera. Beyond that, you may need to experiment. – Leigh May 29 '12 at 17:18

2 Answers2

3

This is the dependency tree for batik-transcoder 1.6-1 using mvn dependency:tree -Dverbose:

[INFO] +- batik:batik-transcoder:jar:1.6-1:compile
[INFO] |  +- batik:batik-bridge:jar:1.6-1:compile
[INFO] |  |  +- batik:batik-gvt:jar:1.6-1:compile
[INFO] |  |  |  \- batik:batik-awt-util:jar:1.6-1:compile
[INFO] |  |  |     \- batik:batik-util:jar:1.6-1:compile
[INFO] |  |  |        \- (batik:batik-gui-util:jar:1.6-1:compile - omitted for duplicate)
[INFO] |  |  +- (batik:batik-bridge:jar:1.6-1:compile - omitted for cycle)
[INFO] |  |  +- batik:batik-script:jar:1.6-1:compile
[INFO] |  |  \- batik:batik-svg-dom:jar:1.6-1:compile
[INFO] |  |     +- batik:batik-dom:jar:1.6-1:compile
[INFO] |  |     |  +- batik:batik-css:jar:1.6-1:compile
[INFO] |  |     |  |  \- (batik:batik-util:jar:1.6-1:compile - omitted for duplicate)
[INFO] |  |     |  +- batik:batik-xml:jar:1.6-1:compile
[INFO] |  |     |  |  \- (batik:batik-util:jar:1.6-1:compile - omitted for duplicate)
[INFO] |  |     |  \- (xerces:xercesImpl:jar:2.5.0:compile - omitted for conflict with 2.2.1)
[INFO] |  |     \- batik:batik-parser:jar:1.6-1:compile
[INFO] |  |        \- (batik:batik-awt-util:jar:1.6-1:compile - omitted for duplicate)
[INFO] |  \- fop:fop:jar:0.20.5:compile
[INFO] |     +- batik:batik-1.5-fop:jar:0.20-5:compile
[INFO] |     +- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |     +- (xalan:xalan:jar:2.4.1:compile - omitted for duplicate)
[INFO] |     +- xerces:xercesImpl:jar:2.2.1:compile
[INFO] |     \- avalon-framework:avalon-framework:jar:4.0:compile
[INFO] +- batik:batik-gui-util:jar:1.6-1:provided (scope not updated to compile)
[INFO] |  \- (batik:batik-ext:jar:1.6-1:provided - omitted for duplicate)
[INFO] +- batik:batik-ext:jar:1.6-1:provided
[INFO] |  \- xml-apis:xmlParserAPIs:jar:2.0.2:provided
[INFO] +- rhino:js:jar:1.5R4.1:provided
[INFO] \- xalan:xalan:jar:2.4.1:provided (scope not updated to compile)

If you use maven you could set some dependencies to <scope>provided</scope>

For example I could exlude these without problems, which saved me ca. 1.6MB:

<dependencies>
...
    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-gui-util</artifactId>
        <version>1.6-1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-ext</artifactId>
        <version>1.6-1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>rhino</groupId>
        <artifactId>js</artifactId>
        <version>1.5R4.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.4.1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

It seems that these are the biggest dependencies:

http://repo.maven.apache.org/maven2/xerces/xercesImpl/2.2.1/xercesImpl-2.2.1.jar (816 KB at 851.9 KB/sec)
http://repo.maven.apache.org/maven2/xalan/xalan/2.4.1/xalan-2.4.1.jar (1007 KB at 479.7 KB/sec)
http://repo.maven.apache.org/maven2/fop/fop/0.20.5/fop-0.20.5.jar (1485 KB at 1011.7 KB/sec)
http://repo.maven.apache.org/maven2/batik/batik-1.5-fop/0.20-5/batik-1.5-fop-0.20-5.jar (2063 KB at 936.0 KB/sec)
Patrick
  • 33,984
  • 10
  • 106
  • 126
1

Not exactly sure what you want to accomplish, but ProGuard will let you filter classes in jars that aren't used by your code.

Peter Svensson
  • 6,105
  • 1
  • 31
  • 31
  • thank you for the help I really appreciate it. I will check out the link. – Jesse May 30 '12 at 18:04
  • I figured it out, I just created a jar file and used java loader on the server. I really appreciate everyone helping me. – Jesse Feb 22 '13 at 19:04