Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubleshooting JPEG #151

Closed
MarcFletcher opened this issue Jul 13, 2015 · 3 comments
Closed

Troubleshooting JPEG #151

MarcFletcher opened this issue Jul 13, 2015 · 3 comments
Assignees

Comments

@MarcFletcher
Copy link

I have another problematic JPEG, although I assume a different problem to the one I reported in issue #22:

I am unable to load the following JPEG, source : http://static.lexpress.fr/medias_9804/w_1970,h_1478,c_crop,x_0,y_0/w_605,h_350,c_fill,g_north/v1409117471/un-nouveau-record-du-chomage-en-france-comme-cadeau-de-bienvenue-manuel-valls-a-prevenu-des-mardi-que-les-chiffres-de-juillet-que-pole-emploi-devoile-mercredi-au-lendemain-de-la-nomination-du-nouveau-gouvernement-ne-seraient-pas-bons_5019824.jpg

Code snippet:

URL url = new URL(imageURLStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//image is null, i.e. read failed
BufferedImage image = ImageIO.read(conn.getInputStream());

I have both the following dependencies confirmed as loaded:

        <dependency>
            <groupId>com.twelvemonkeys.imageio</groupId>
            <artifactId>imageio-jpeg</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.twelvemonkeys.imageio</groupId>
            <artifactId>imageio-tiff</artifactId>
            <version>3.1.1</version>
        </dependency>

I have several example of images from the same website that suffer from this problem. Any help with this type of image would be greatly appreciated.

@haraldk haraldk self-assigned this Jul 13, 2015
@haraldk
Copy link
Owner

haraldk commented Jul 13, 2015

Hi,

Thanks for reporting!

However, I just downloaded your linked image, and it reads just fine using code similar to your snippet.

public static void main(String[] args) throws IOException {
    URL url = new URL(args[0]);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    //image is null, i.e. read failed
    BufferedImage image = ImageIO.read(conn.getInputStream());
    System.err.println("image: " + image);
    JPEGImageReader.showIt(image, "image"); // NON-API, just to show the contents looks good
}

Best regards,

Harald K

@MarcFletcher
Copy link
Author

How annoying ;) After doing some further digging it looks like i was getting the image from a CDN node (where the image was corrupted). If I used a VPN endpoint in a different country the above worked ok.

Many kind thanks for the v.quick response and apologies that I didn't think of trying this before posting.

@haraldk
Copy link
Owner

haraldk commented Jul 14, 2015

Ok!

No problem!

Harald K

@haraldk haraldk closed this as completed Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants