• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pkiraly / metadata-qa-api / #652

15 Apr 2025 10:29AM UTC coverage: 86.972% (-0.3%) from 87.272%
#652

push

pkiraly
Release v0.9.7

5494 of 6317 relevant lines covered (86.97%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/src/main/java/de/gwdg/metadataqa/api/util/ImageDimensionExtractor.java
1
package de.gwdg.metadataqa.api.util;
2

3
import javax.imageio.ImageIO;
4
import java.awt.image.BufferedImage;
5
import java.io.File;
6
import java.io.IOException;
7
import java.io.InputStream;
8
import java.net.HttpURLConnection;
9
import java.net.URL;
10

11
public class ImageDimensionExtractor {
×
12
  public static DimensionDao extractRemote(String url) throws IOException {
13
    URL urlObj = new URL(url);
1✔
14

15
    HttpURLConnection urlConnection = (HttpURLConnection) urlObj.openConnection();
1✔
16

17
    int timeout = 2000;
1✔
18
    urlConnection.setConnectTimeout(timeout);
1✔
19
    urlConnection.setReadTimeout(timeout);
1✔
20
    urlConnection.connect();
1✔
21
    int responseCode = urlConnection.getResponseCode();
1✔
22
    if (responseCode == 200) {
1✔
23
      InputStream in = urlConnection.getInputStream();
×
24
      BufferedImage img = ImageIO.read(in);
×
25
      if (img == null) {
×
26
        return null;
×
27
      }
28
      return new DimensionDao(img.getWidth(), img.getHeight());
×
29
    } else if (responseCode == 301 || responseCode == 303) {
1✔
30
      String location = urlConnection.getHeaderField("Location");
×
31
      return extractRemote(location);
×
32
    }
33
    return null;
1✔
34
  }
35

36
  public static DimensionDao extractLocal(String filename) throws IOException {
37
    BufferedImage img = ImageIO.read(new File(filename));
×
38
    return new DimensionDao(img.getWidth(), img.getHeight());
×
39
  }
40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc