Under Java what is the best way to go about converting an TIF file to a PNG?
Simplicity is preferable, but if the simplest way is to use a third party library then I would consider that solution.
Under Java what is the best way to go about converting an TIF file to a PNG?
Simplicity is preferable, but if the simplest way is to use a third party library then I would consider that solution.
Java advanced imaging APi is a good library for image manipulations
First, install JAI. Then install JAI/ImageIO. Then do
public static void main(final String[] args) throws Exception
{
final BufferedImage tif = ImageIO.read(new File("test.tif"));
ImageIO.write(tif, "png", new File("test.png"));
}
Use imageMagic java libraries like im4java, their performance and quality is much better then JAI
for example:
import org.im4java.core.ConvertCmd;
import org.im4java.core.IMOperation;
public static void convertTifToPng(File inputImage, File outputImage){
IMOperation op = new IMOperation();
op.addImage(); //place holder for input file
op.addImage(); //place holder for output file
ConvertCmd convert = new ConvertCmd();
convert.run(op, new Object[]{inputImage.getAbsolutePath(), outputImage.getAbsolutePath()});
}
maven dependency for im4java is
<dependency>
<groupId>im4java</groupId>
<artifactId>im4java</artifactId>
<version>0.98.0</version>
</dependency>