/**
         *  Determine the type of an image
         */
        public static Value exif_imagetype(Env env, string file)
        {
            try {
                Iterator it = ImageIO.getImageReaders(file.openRead());
                if (!it.hasNext())
                {
                    return(BooleanValue.FALSE);
                }
                ImageReader imageReader = (ImageReader)it.next();
                if (it.hasNext())
                {
                    throw new QuercusException("ImageIO returned two ImageReaders:\n  "
                                               + imageReader + "\n  " + it.next());
                }
                string formatName = imageReader.getFormatName();
                if (formatName.equals("jpeg") || formatName.equals("jpg"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_JPG));
                }
                if (formatName.equals("gif"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_GIF));
                }
                if (formatName.equals("png"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_PNG));
                }
                if (formatName.equals("swf"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_SWF));
                }
                if (formatName.equals("psd"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_PSD));
                }
                if (formatName.equals("bmp"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_BMP));
                }
                if (formatName.equals("tiff"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_TIFF_II));
                }

                /*
                 * // XXX: check byte order
                 * if (formatName.equals("tiff"))
                 * return ImageModule.IMAGETYPE_TIFF_MM;
                 */
                if (formatName.equals("jpc"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_JPC));
                }
                if (formatName.equals("jp2"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_JP2));
                }
                if (formatName.equals("jpf"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_JPX));
                }
                if (formatName.equals("jb2"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_JB2));
                }
                if (formatName.equals("swc"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_SWC));
                }
                if (formatName.equals("iff"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_IFF));
                }
                if (formatName.equals("wbmp"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_WBMP));
                }
                if (formatName.equals("xbm"))
                {
                    return(LongValue.create(ImageModule.IMAGETYPE_XBM));
                }
                env.warning(L.l("ImageIO returned unknown image type: " + formatName));
                return(BooleanValue.FALSE);
            }
            catch (IOException e)
            {
                throw new QuercusException(e);
            }
        }