I have an image url like,
String url = "http://XXXXXXX/img_High-Octane-Sauce-Company-JP5-400x1024.jpg";
I need this to be take as an input to the method,
ImageInputStream in = ImageIO.createImageInputStream( urlInputHere );
so I can read the width and height of the image without using image buffer. Can anyone please tell me how to do this?
This is the way I am reading the image
ImageInputStream in = ImageIO.createImageInputStream(resourceFile);
try {
final Iterator<ImageReader> readers = ImageIO.getImageReaders(in);
if (readers.hasNext()) {
ImageReader reader = readers.next();
try {
reader.setInput(in);
return new Dimension(reader.getWidth(0), reader.getHeight(0));
} finally {
reader.dispose();
}
}
} finally {
if (in != null) in.close();
}
P.S. Taken from : Java/ImageIO getting image dimensions without reading the entire file?