1

I'm using the im4java library to convert svg files to png files. I want the transparent backgrounds to remain transparent but they always become white. This is the operation I'm using:

IMOperation hdpiOperation = new IMOperation();
hdpiOperation.addImage();
hdpiOperation.background("none");
hdpiOperation.addImage();

If I manually try with ImageMagick from the commandline using this command it does work:

convert -background none a.svg b.png

Any ideas?

dzan
  • 425
  • 3
  • 14
  • either im4java picks alternative `convert` executable or it is susceptable to option order (try to move `background("none")` method one line up. – barti_ddu Aug 13 '12 at 15:58
  • The issue was the order! I thought that I had to add the Image first. ( how can I accept your answer on stackoverflow? ) – dzan Aug 15 '12 at 14:54
  • posted comment as an answer; but variety of imagemagick builds drives me crazy (mine does work properly in both cases and even without `-background` option) :) – barti_ddu Aug 15 '12 at 21:29

1 Answers1

1

Since im4java appends parameters in method execution order, you can move hdpiOperation.background("none") call before image placeholders to mimic working 'raw' command:

hdpiOperation.background("none");
hdpiOperation.addImage();
hdpiOperation.addImage();
barti_ddu
  • 10,179
  • 1
  • 45
  • 53