Loading...
Logo
Processing Forum
Hi all,

I'm working on an art project that crawls the web for specific images and run into the following loadImage() problem for some of the images (most of them do work):
Copy code
  1. String imgURL = "http://www.ikonrtv.nl/uploads/uploadedImgs/alfred hitchcock.jpg";
    PImage img = null;
    try {
      img = loadImage(imgURL);
    }
    catch (Exception e) {
      println("Exception "+e);
    }
    size(600, 600);
    if (img != null) image(img, 0, 0);
    println("Done");
For this specific URL the whole thing hangs: no exception error, no timeout, no 'Done'... So it hangs up my entire script.
When I paste the URL into a browser the image shows up fine.
When I use a different URL for instance "http://farm2.staticflickr.com/1267/1396796938_95aaceee6a_z.jpg" everything works fine...

How to fix this? Using a proxy or so? It's really very annoying!


Thanks!

Rolf van Gelder


Replies(3)

Oops, posted that just one minute too fast

Suddenly realized that the 'space' in the URL could cause the problem and it did!

So, if I change to URL to "http://www.ikonrtv.nl/uploads/uploadedImgs/alfred%20hitchcock.jpg" it works fine.

Sorry to bother you!

Rolf
javascript encodes space as %20,
the correct url is http://www.ikonrtv.nl/uploads/uploadedImgs/alfred%20hitchcock.jpg
(right click on alfred's face, copy image link and paste it into processing).
" javascript encodes space as %20"
Not really. That's the normal escaping of URLs, nothing to do with JavaScript.
Note that you can also encode them with +
http://www.ikonrtv.nl/uploads/uploadedImgs/alfred+hitchcock.jpg

Last note: move size() at the top of setup() (I wish to get 1 € for each time I write this! )

[EDIT] In this case, the + is rejected by this specific server! Strange... So use %20 anyway.