String outputMimeType) throws Exception {
if (outputMimeType.equals("image/gif")) {
if (!alreadyConvertedToRGB) {
ip = ip.convertToRGB();
}
MedianCut mc =
new MedianCut((int[]) ip.getPixels(), ip.getWidth(), ip
.getHeight());
ip = mc.convertToByte(256);
ImagePlus imp = new ImagePlus("temp", ip);
FileInfo fi = imp.getFileInfo();
byte pixels[] = (byte[]) imp.getProcessor().getPixels();
GifEncoder ge =
new GifEncoder(fi.width,