> Hi, I'm using Batik 1.5beta4 under JDK 1.4.1 on Windows 2000, and I'm > trying to convert svg files to gif. The "ConvertSVGtoGIF" program works > fine as long as I only have 3 colors in the svg file, any more and I get > the following error: > > Exception in thread "main" > org.apache.batik.transcoder.TranscoderException: null > > Enclosed Exception: > null > Enclosed Exception: > too many colors for a GIF > at > org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown > Source) > at > org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown > Source) > at ConvertSVGtoGIF.main(ConvertSVGtoGIF.java:35) > > It seems that the transcoder thinks there are more than 256 colors in the > SVG file, but this is not so. I've used the ACME GIFEncoder and the > following GIFTranscoder that I found posted on this mailing list (see the > link below for the code for the GIFTranscoder: > > http://koala.ilog.fr/batik/mlists/batik-users/archives/msg00753.html > > I'll include all of the code that links to this problem now: > > The code for my ConvertSVGtoGIF java program is shown below: > > import java.io.*; > import org.apache.batik.transcoder.image.JPEGTranscoder; > import org.apache.batik.transcoder.TranscoderInput; > import org.apache.batik.transcoder.*; > import net.sourceforge.xweb.backend.images.*; > > public class ConvertSVGtoGIF > { > > public static void main(String [] args) throws Exception > { > // create a GIF transcoder > GIFTranscoder t = new GIFTranscoder(); > > /* create the transcoder input by taking the file name > * given on the command line > */ > String svgURI = new File(args[0]).toURL().toString(); > TranscoderInput input = new TranscoderInput(svgURI); > // create the transcoder output > > OutputStream ostream = new FileOutputStream("out.gif"); > TranscoderOutput output = new TranscoderOutput(ostream); > // save the image > t.transcode(input, output); > > // flush and close the stream then exit > ostream.flush(); > ostream.close(); > System.exit(0); > } > } > > The skeleton of the offending SVG file that gives the errors is listed > bellow: > > <?xml version="1.0" encoding="ISO-8859-1"?> > <?xml-stylesheet href="style1.css" type="text/css"?> > > <svg width="1000" height="1000" viewBox="0 0 1000 1000" > xmlns="http://www.w3.org/2000/svg" > xmlns:xlink="http://www.w3.org/1999/xlink"> > <defs> > <path id="castle" class="castle" > d="M 0 0 L 0 10 L 10 10 L 10 0 L 8 0 L 8 4 L 6 4 L 6 0 L 4 > 0 L 4 4 L 2 4 L 2 0 z" /> > <path id="zoo" class="zoo" > d="M 0 0 L 5 0 L 0 7 L 5 7" /> > </defs> > <g id="TOWNS"> > <polygon id="Didcot" class="town" > points="515,481 528,484 540,490 543,500 538,508 517,510 > 510,508 515,481 515,481"/> > </g><!-- End of Towns --> > <g id="ROADS"> > <polyline id="M40 Spur" class="motorway" > points="635,357 618,350 635,357"/> > </g><!-- End of roads --> > <g id="ATTRACTIONS"> > <use xlink:href="#castle" x="200" y="200" id="Blenheim"/> > <use xlink:href="#zoo" x="250" y="250" id="AZoo"/> > </g><!-- End of attractions --> > <g id="LABELS"> > <text id="Oxford" class="city" x="495" y="328">Oxford</text> > </g><!-- End of labels --> > </svg> > > And the CSS Stylesheet just for reference ....... > > polyline.minorA > { > fill: none; > stroke: crimson; > stroke-width: 0.5 > } > polyline.majorA > { > fill: none; > stroke: limegreen; > stroke-width: 0.75 > } > polyline.motorway > { > fill: none; > stroke: cornflowerblue; > stroke-width: 0.5 > } > polygon.town > { > fill: grey; > stroke-width: 4 > } > path.castle > { > fill: black; > } > path.zoo > { > stroke: black; > stroke-width: 1; > fill: none > } > text.city > { > fill: black; > } > > Hope someone can help me!! > > Thanks, Phil > > > > >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]