Loads an image from the supplied input stream. Supports formats supported by {@link ImageIO}
but not {@link FastImageIO}.
346949
protected static BufferedImage loadImage (InputStream iis)
        throws IOException
    {
        BufferedImage image;

        if (iis instanceof ImageInputStream) {
            image = ImageIO.read(iis);

        } else {
            // if we don't already have an image input stream, create a memory cache image input
            // stream to avoid causing freakout if we're used in a sandbox because ImageIO
            // otherwise use FileCacheImageInputStream which tries to create a temp file
            MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(iis);
            image = ImageIO.read(mciis);
            try {
                // this doesn't close the underlying stream
                mciis.close();
            } catch (IOException ioe) {
                // ImageInputStreamImpl.close() throws an IOException if it's already closed;
                // there's no way to find out if it's already closed or not, so we have to check
                // the exception message to determine if this is actually warning worthy
                if (!"closed".equals(ioe.getMessage())) {
                    log.warning("Failure closing image input '" + iis + "'.", ioe);
                }
            }
        }

        // finally close our input stream
        StreamUtil.close(iis);

        return image;
    }
1098394
public static HashMap<String, Integer> getImageInfo(ImageInputStream input) {
        HashMap<String, Integer> map = new HashMap<String, Integer>(2);

        BufferedImage buff = null;
        try {
            buff = ImageIO.read(input);
            map.put("width", buff.getWidth());
            map.put("height", buff.getHeight());
            return map;
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
372748
public static String getImageFormat(ImageInputStream input) {
        Iterator<ImageReader> readers = ImageIO.getImageReaders(input);
        String format = "unknown";
        if (readers.hasNext()) {
            ImageReader reader = readers.next();
            try {
                format = reader.getFormatName();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                reader.dispose();
            }
        }

        return format;
    }
538849
public static String read(InputStream input) throws IOException, NotFoundException {
        BufferedImage image = ImageIO.read(input);
        return read(image);
    }
865583
public static Image load(String path)
  {
    BufferedImage image = null;

    try
    {
      InputStream in = ImageUtils.class.getClassLoader().getResourceAsStream(path);
      image = ImageIO.read(in);
      in.close();
    }
    catch (Exception e)
    {
      throw new RuntimeException("Could not load image with path: " + path, e);
    }

    return image;

  }
217280
public void load(final InputStream is, final String encoding) throws IOException {
		load(new InputStreamReader(is, encoding));
	}
1196543
public static ImageInputStream getImageInputStream(InputStream in) throws IORuntimeException {
		try {
			return ImageIO.createImageInputStream(in);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
1012014
public void load(InputStream inputStream)
	{

		try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)))
		{
			while ((currentLine = reader.readLine()) != null)
			{
				lineNumber++;
				currentLine = currentLine.replaceAll("\\s+", " ").trim();
				matcher = linePattern.matcher(currentLine);

				if (matcher.matches())
				{
					String type = matcher.group("type");
					String data = matcher.group("data");

					switch (type)
					{
						case "v":
							addVertex(data);
							break;
						case "vn":
							addNormal(data);
							break;
						case "vt":
							addUV(data);
							break;
						case "f":
							addFace(data);
							break;
						case "g":
						case "o":
							addShape(data);
							break;

						default:
							MalisisCore.log.debug("[ObjFileImporter] Skipped type {} at line {} : {}", type, lineNumber, currentLine);
							break;
					}
				}
				else
				{
					MalisisCore.log.debug("[ObjFileImporter] Skipped non-matching line {} : {}", lineNumber, currentLine);
				}
			}

			addShape("");
		}
		catch (Exception e)
		{
			MalisisCore.log.error("[ObjFileImporter] An error happened while reading the file : {}", e);
		}
	}
682029
@Override
    public Directory read(final ImageInputStream input) throws IOException {
        Validate.notNull(input, "input");

        List<PSDEntry> entries = new ArrayList<>();

        while (true) {
            try {
                int type = input.readInt();

                switch (type) {
                    case PSD.RESOURCE_TYPE_IMAGEREADY:
                    case PSD.RESOURCE_TYPE_PHOTODELUXE:
                    case PSD.RESOURCE_TYPE_LIGHTROOM:
                    case PSD.RESOURCE_TYPE_DCSR:
                        // TODO: Warning for these types!
                    case PSD.RESOURCE_TYPE:
                        break;
                    default:
                        throw new IIOException(String.format("Wrong image resource type, expected '8BIM': '%08x'", type));
                }

                short id = input.readShort();

                PSDResource resource = new PSDResource(id, input);
                entries.add(new PSDEntry(id, resource.name(), resource.data()));

            }
            catch (EOFException e) {
                break;
            }
        }

        return new PSDDirectory(entries);
    }
1367564
public static ImageInfo read(InputStream in) throws IOException {
        ImageInfo imageInfo = new ImageInfo();
        imageInfo.setInput(in);
        if (!imageInfo.check()) {
            throw new IOException("ImageInfo.check() failed; data stream is "
                    + "broken or does not contain data in a supported image format");
        }
        return imageInfo;
    }
108886
public static BufferedImage read(ImageInputStream imageStream) {
		try {
			return ImageIO.read(imageStream);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
1006076
@Override
   public Image loadImage(URL image, float opacity) throws VectorPrintException {
      try {
         if (log.isLoggable(Level.FINE)) {
            log.fine(String.format("loading image from %s", String.valueOf(image)));
         }
         BufferedImage awtim = null;
         if ("file".equals(image.getProtocol())) {
            awtim = makeImageTranslucent(ImageIO.read(new File(image.getFile())), opacity);
         } else {
            awtim = makeImageTranslucent(ImageIO.read(image), opacity);
         }
         return Image.getInstance(awtim, null);
      } catch (BadElementException | IOException ex) {
         throw new VectorPrintException(String.format("unable to load image %s", image.toString()), ex);
      }
   }
971927
public InputStream loadTemplate(String fileName) throws IOException {
	Path currentPath=new Path(fileName);
	return openFile(currentPath);
}
33684
public static BufferedImage loadImage(String fileName){
		File f = new File(fileName);
		if(f.exists()){
			return loadImage(f);
		}
		throw new ImageLoaderException(new FileNotFoundException(fileName));
	}
1113630
public static byte[] loadBytesFromStream(InputStream stream) {
		try {
			BufferedInputStream bis = new BufferedInputStream(stream);
			byte[] theData = new byte[10000000];
			int dataReadSoFar = 0;
			byte[] buffer = new byte[1024];
			int read = 0;
			while ((read = bis.read(buffer)) != -1) {
				System.arraycopy(buffer, 0, theData, dataReadSoFar, read);
				dataReadSoFar += read;
			}
			bis.close();
			// Resize to actual data read
			byte[] returnData = new byte[dataReadSoFar];
			System.arraycopy(theData, 0, returnData, 0, dataReadSoFar);
			return returnData;
		}
		catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
428712
public JSONObject imageCensorUserDefined(String image, EImgType type, HashMap<String, String> options) {
        if (type == EImgType.FILE) {
            try {
                byte[] imgData = Util.readFileByBytes(image);
                return imageCensorUserDefined(imgData, options);
            } catch (IOException e) {
                return AipError.IMAGE_READ_ERROR.toJsonResult();
            }
        }

        // url
        AipRequest request = new AipRequest();

        request.addBody("imgUrl", image);

        return imageCensorUserDefinedHelper(request, options);
    }
1304532
public static ImageFormat getImageFormat_WrapIOException(final InputStream is) {
    try {
      return getImageFormat(is);
    } catch (IOException ioe) {
      throw Throwables.propagate(ioe);
    }
  }