Rectangle 27 0

I would search for ImageMagick Application Programmer Interfaces. They have interfaces for every significant language.

I find the Java philosophy is to extensively research what already exists, find the best solution for your needs, then write the minimal code needed to interface to it. This is a pure Java way.

Convert PPM to JPG or BMP in java - Stack Overflow

java bmp ppm
Rectangle 27 0

Beside the old Sun JAI implementation there are additional ImageIO plugins TwelveMonkeys ImageIO which extend the ImageIO implementation in the JDK/JRE.

Below is a small example using those plugins. The example depends on version 3.1-SNAPSHOT (earlier release version does not provide PNM support). So you need to build the plugin project first.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" 
package sub.optimal.jai;

import java.awt.image.BufferedImage;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import javax.imageio.ImageIO;

 * @author SubOptimal
public class Main {

    public static void main(String[] args) throws IOException {
        String outFormat = "%-17s: %s%n";

        String filesDirectory = System.getProperty("user.dir");
        System.out.printf(outFormat, "files directory", filesDirectory);

        System.out.printf(outFormat, "supported formats", Arrays.toString(ImageIO.getWriterFormatNames()));

        Path inputFile = Paths.get(filesDirectory, "pond.ppm");
        System.out.printf(outFormat, "input file", inputFile.toAbsolutePath());
        InputStream is = Files.newInputStream(inputFile, StandardOpenOption.READ);
        BufferedImage image =;

        File outputFile = Paths.get(filesDirectory, "output.jpg").toAbsolutePath().toFile();
        System.out.printf(outFormat, "output file", outputFile.getAbsolutePath());

        boolean writeSuccess = ImageIO.write(image, "JPEG", outputFile);
        System.out.printf(outFormat, "write successful", writeSuccess);

Build and run the example code.

mvn clean compile exec:java

Thanks, I just replaced the name "JAI" with "ImageIO" in your answer, as we really don't extend or provide plugins to JAI, only standard ImageIO (which is usually all you need). :-)

Convert PPM to JPG or BMP in java - Stack Overflow

java bmp ppm