简体   繁体   中英

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM