"The Java Image Management Interface," Volume: 3  Issue: 11, p. 46

Listing 1.
Basic image conversion with JIMI

import com.activated.jimi.*;
import java.awt.Image;

public class JimiIsReallyEasy {
 public static void main(String[] args)
  throws JimiException {
  Image image = Jimi.getImage("myImage.PSD");
  Jimi.putImage(image, "myImage.PNG");
  System.exit(0);
 }
}

Listing 2.
Reading and writing multiple image files

import com.activated.jimi.*;

import java.awt.*;
import java.util.*;

/**
 * A simple example program for reversing the
 * order of frames in a multi-frame image.
 */
public class ImageSeriesReverser
{
 public static void main(String[] args)
 {
  // print usage if wrong arguments are given
  if (args.length != 2) {
   System.err.println("Requires args: <src> <dest>");
   System.exit(1);
  }

  // vector to store loaded images in
  Vector images = new Vector();

  // read the images
  try {
   // create a JimiReader to read the image
   // series from
   JimiReader jr = Jimi.createJimiReader(args[0]);
   // enumerate the images in the series
   Enumeration e = jr.getImageEnumeration();
   // insert them into the vector in reverse
   while (e.hasMoreElements()) {
    Image i = (Image)e.nextElement();
    images.insertElementAt(e, 0);
   }
  }
  // catch exception if the source file
  // is malformed
  catch (JimiException e) {
   System.err.println("Error: " + e);
   System.exit(1);
  }
  // write the images back in reverse
  try {
   // create a JimiWriter for the output file
   JimiWriter jw = Jimi.createJimiWriter(args[1]);
   // pull the images out of the vector and
   // into an array
   Image[] series = new Image[images.size()];
   images.copyInto(series);
   // set the image array as the source for
   // the JimiWriter
   jw.setSource(series);
   // write the images!
   jw.putImage(args[1]);
  }
  // catch exception if the output file
  // can't be written to
  catch (JimiException e) {
   System.err.println("Error: " + e);
   System.exit(1);
  }
  // finished!
  System.exit(0);
 }
}

Listing 3.
Image Processing example method

public JimiBufferedRasterImage flipImage(JimiRasterImage source)
 throws ImageAccessException
{
 // the dimensions of the source image, which
 // are used to create a same-sized target image
 int width = source.getWidth();
 int height = source.getHeight();
 // create an empty target image to populate
 // with flipped data
 JimiBufferedRasterImage target =
  Jimi.createBufferedRasterImage(width,height);
 // a small buffer for pixel data to copy-between
 int[] rowBuffer = new int[width];
 // the index of the last row of the image
 int lastRow = height - 1;
 // loop through, copying each row from source to destination
 for (int row = 0; row < height; row++) {
  // get the source row
  source.getRowRGB(row, rowBuffer, 0);
  // copy it into the destination image at the
  // opposite location

  target.setRowRGB(lastRow-row, rowBuffer, 0);
 }
 // all finished, the target image is now fully populated
 return target;
}