Search code examples
javacoldfusionbatik

Can I use only the Transcoder of the Batik library without all other Batik code and dependencies?


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?


Solution

  • 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)