Search code examples
processxserverinkscape

Running inkscape without X server


I am running inkscape from a Gearman PHP process on *nix-like systems (OS X 10.6.8, Linux of varying flavours) to convert SVG images to either PNG or PDF. I use something like this (line breaks added here just for clarity):

/full/path/to/inkscape -z \
    --export-png=/path/to/output.png \
    --export-width=100 --export-height=100 \
    /path/to/input.svg

It works, but despite the -z flag ("Do not use X server") I get this in my console output (on OS X):

Setting Language: .UTF-8

(process:44699): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
Xlib:  extension "RANDR" missing on display "/tmp/launch-WvcqRh/org.x:0".

This suggests to me that inkscape is loading more libraries than it needs to, and that it could be faster if it didn't try to connect to an X server. However, other than using the -z/--without-gui flag, I am not sure what to try. Performance on my dev machine is still sub-second (at least for trivial SVG files), but I'd like to clean this up if I can. Even if the best answer is just "suppress error output"!

Maybe if I turn off or reset a bash DISPLAY env var? I'm not at all familiar with X.


Solution

  • Yes, if you want to make your programs not find X at all, you can unset DISPLAY before launching the process.

    You can also use Xvfb to "fake" an X server: http://en.wikipedia.org/wiki/Xvfb

    You might also want to look at these tools:

    Their source code is really small.