public static BufferedImage read(Object img) {
		try {
			if (img instanceof File)
				return ImageIO.read((File) img);
			else if (img instanceof URL)
				img = ((URL) img).openStream();
			if (img instanceof InputStream) {
				File tmp = File.createTempFile("demos_img", ".jpg");
				FileHelper.write(tmp, (InputStream)img);
				tmp.deleteOnExit();
				return read(tmp);
			}
			return null;
		}
		catch (IOException e) {
			try {
					InputStream in = null;
					if (img instanceof File)
						in = new FileInputStream((File)img);
					else if (img instanceof URL)
						in = ((URL)img).openStream();
					else if (img instanceof InputStream)
						in = (InputStream)img;
					if (in != null)
						return readJpeg(in);
			} catch (IOException e2) {
				e2.fillInStackTrace();
			}
			return null;
			//throw Lang.wrapThrow(e);
		}
	}