Given a URL like:
https://media.deltafaucet.com/elvis/OnWhite/lg/58471-SS-PK-B1.png
I want to extract the information such as:
1. Address (the url)
2. Type (file type e.g: image/png)
3. Render Mode (Quirks mode)
4. Modified date
5. Image Format (JPN or png)
6. resolution (no the scaled size)
These information are available on Firefox after right-clicking on the image and selecting 'view image info'.
I want to be able to extract these info without having to download them.
what class/methods are available? I can't seem to find any.
I tried selenium but realized that it is UI based, and so couldn't get these info.
Asked
Active
Viewed 1,340 times
0

shsulabh
- 1
- 2
-
2When the browser displays the information, it has already downloaded the image. There is no way to remotely get these information. – Flown Jun 16 '17 at 05:49
-
1@Flown You are of course right. But I think you can get everything except the resolution (and render mode, which I don't think applies for images), by doing a HEAD request. With no request at all, you can still get 1, 2 (from file extension) and 5. – Harald K Jun 20 '17 at 11:22
1 Answers
0
I am sharing my snippet of code which is working.
URL url = new URL("url");
InputStream in = url.openStream();
Reader reader = new InputStreamReader(in, "UTF-8"); // for example..change format according to your req
Properties prop = new Properties();
try {
prop.load(reader);
} finally {
reader.close();
}
System.out.println( prop.getProperty("key"));
Make sure the Reader (and thereby the InputStream) is properly closed when you're done with it.Also handle your try-catch as you need. Hope that helps.

Akshay
- 1,161
- 1
- 12
- 33