Talk:SVG benchmarks

From MediaWiki.org
Jump to navigation Jump to search

Suggestion (2010)[edit]

Maybe you want to try again with this:

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;

import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.PNGTranscoder;

/**
 * Argument: Filename of a file with two filenames on each line, separated by a tab character. The
 * first filename is the url of an input file, the second the name of the output file.
 */
public class BatikServ {
   public static void main(String args[]) throws Exception {
      if (args.length < 1) {
         System.err.println("Usage: java BatikServ <urlfile>");
         System.exit(1);
      }

      File urlfile = new File(args[0]);
      BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(urlfile)));
      String line = null;
      while ((line = reader.readLine()) != null) {
         String[] files = line.split("\t", 2);
         renderImage(files[0], files[1]);
      }
      reader.close();
   }

   public static void renderImage(String svgFile, String targetFile) throws TranscoderException, IOException {
      PNGTranscoder t = new PNGTranscoder();
      TranscoderInput input = new TranscoderInput(svgFile);
      OutputStream out = new FileOutputStream(targetFile);
      TranscoderOutput output = new TranscoderOutput(out);
      t.transcode(input, output);

      out.flush();
      out.close();
   }
}

-- chris — Preceding unsigned comment added by 212.98.60.100 (talkcontribs)

Have you tried out KSVG2? This is apparently the lib that has been folded into WebKit. Might be a good alternative to rsvg - fewer dependencies? — Preceding unsigned comment added by 67.183.216.180 (talkcontribs)

An alternative for ImageMagick on an external server[edit]

I have a wiki on a server which is not mine. The wiki should be able to render SVG images, but ImageMagick sucks very nicely; it renders some SVG:s very badly. Well, I found out that Wikipedia uses rsvg. The server administrator doesn't want to install rsvg globally for me, so I decided to compile it by hand on my server's home directory but they have blocked gcc from me. Then I thought that maybe I could find a binary that I could download on my server, but no, I couldn't find any. The server is probably running Fedora Core. What could I do? --Erkkimon — Preceding unsigned comment added by 87.93.11.176 (talkcontribs)

Get a better hosting company - David Gerard 14:55, 15 July 2010 (UTC)
I have found that the fastest to implement and fastest-performing headless SVG rendering solution is PhantomJS (native, headless, scriptable webkit). On my CentOS6 virtual machine rendering a large production graphic SVG to PNG is up to 7 times faster under PhantomJS than Batik. Loooooooooong live Java. -MKW 11-19-2014 — Preceding unsigned comment added by 74.92.36.81 (talkcontribs)