Troubles loading and viewing SVG files

edited November 2014 in Questions about Code


I'm trying to make my sketch suitable for various sizes and resolutions of screen, and thus would like to use PShapes instead of PImages.

However, I came across many problems with loading and displaying SVG files in Processing (I tried first stable release of processing v 2, now I'm working with latest3.0a5). I tried to resave all SVG files with Inkscape to Inkscape SVG and SVG plain format. No luck. Do SVG files need to be made in some particular way to be able to work with them in Processing?

I am developing in JAVA mode, bude would like to have my app working on Android and also with Javascript mode.

Below are few example of the issues:


Build messages: Ignoring inkscape:path-effect tag. Ignoring clipPath tag. Ignoring inkscape:perspective tag.

issue part of the image is missing


Build messages: Filters are not supported.

issue Loads without white color in the middle


Build messages: Exception in thread "Animation Thread" java.lang.NullPointerException at processing.core.PShapeSVG.parseStyleAttributes( at processing.core.PShapeSVG$Gradient.( at processing.core.PShapeSVG$LinearGradient.( at processing.core.PShapeSVG.parseChild( at processing.core.PShapeSVG.parseChildren( at processing.core.PShapeSVG.( at processing.core.PShapeSVG.parseChild( at processing.core.PShapeSVG.parseChildren( at processing.core.PShapeSVG.( at processing.core.PShapeSVG.( at processing.core.PGraphicsJava2D.loadShape( at processing.core.PGraphicsJava2D.loadShape( at processing.core.PApplet.loadShape( at test.setup( at processing.core.PApplet.handleDraw( at processing.core.PGraphicsJava2D.requestDraw( at at Source)

issue Does not build at all..

Code i am using to test display of svg files: PShape euro;

void setup() {
  euro = loadShape("2euro.svg");

void draw() {

Many thanks Martin



  • Answer ✓

    The problem with Processing's SVG support (and they are (or were) explicit about this) is that it is quite limited. On purpose: full support is difficult (an enormous effort) and would bloat the runtime. A library like Batik would be better suited for such support.

    On the first two examples, the library is explicit about what is not supported. On the last one, it looks like a bug. Perhaps you should open an issue about this one.

  • Thanks for the response.

    I understand that support is somewhat limited, but I didn't manage to find what are the limitations, or in another words, how should be SVG files made so that processing can work with them (e.g. they should no contain gradient fills or layers or whatever)

    As I have no previous experience with Java, is there some good tutorial to learn how to incorporate batik into my sketch?

    PS: bug reported here:

  • Well, the messages are explicit: if a tag or property is ignored, it should be avoided... Of course, it is harder with a file generated by a tool like Inkscape.

    As you see, there is no support for clipping, masking, filters, etc. And for proprietary tags like the Inkscape ones (use stripped SVG).
    Processing SVG do support gradients, at least a simple version of them.

    Honestly, I wrote about Batik, because it is the most complete SVG implementation in Java, but I am not sure it is usable inside a sketch.

Sign In or Register to comment.