Frage

How can I create an empty, transparent canvas using im4java.

Using the Commandline, I can do this using:

convert.exe -size "64x32" canvas:transparent out.png

But using im4java, I am stuck at the canvas command:

ConvertCmd cmd = new ConvertCmd();
IMOperation io = new IMOperation();
io.size(64,32);
//how to add the canvas command here?
io.addImage(); //output
cmd.run(io, "out.png");

But this only throws an error that it cannot find the out.png. So I assume it wants to use it as input image.

How can I create a new Image?

War es hilfreich?

Lösung

I have found the solution myself:

ConvertCmd cmd = new ConvertCmd();
IMOperation io = new IMOperation();
io.size(64,32);
io.addRawArgs("canvas:#00000000");
io.addImage(); //output
cmd.run(io, "out.png");

The 4th line creates a fully transparent image.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top