Reputation: 7013
I'm doing some coding in JSP/Java (without any framework, or other strange things) and I get stuck trying to find a way to check if a remote image (by URL) meets some specifications, like some defined height and width.
Is there a way to do this in JSP/Java? It's quite easy in PHP, but I can't find the way here ...
Thanks for your time. Best regards.
Upvotes: 0
Views: 335
Reputation: 108899
The simplest way if probably to use the ImageIO class to create a BufferedImage, though it isn't the only mechanism in the standard library.
public static void main(String[] args) throws IOException {
URL imageUrl = new URL("http://www.google.com/intl/en_ALL/images/logo.gif");
BufferedImage image = ImageIO.read(imageUrl);
System.out.println("Width="+image.getWidth());
System.out.println("Height="+image.getHeight());
}
Upvotes: 4