Search code examples
imageimagemagickim4java

Im4Java (ImageMagick) convert 8 bit png to 24 bit png


I need to convert a 8 bit png image into 24 or 32 bit png.

I understand the corresponding image magic command to convert this is:

convert test.png PNG24:test2.png

What ImageOperation property should be used to pass PNG24 argument to convert the image to 24 bit.

I have the current java code snippet something like below:

IMOperation op = new IMOperation();
                op.addImage();
                op.background("none");
                op.autoOrient(); 
                 op.addImage();
               //What should I add for converting it to a PNG24 format???
                convert.run(op,sourceFile,destFile);

The input image is a 8 bit png.


Solution

  • After some research this is what I did to fix it.

    IMOperation op = new IMOperation();
                    op.addImage();
                    op.background("none");
                    op.autoOrient(); 
                     op.addImage();
                    //Added the following line to fix it
                    destFile = "png32:"+destFile;
                    convert.run(op,sourceFile,destFile);