# ImageLoader, Could not find a method to load

**URL:** <https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867>\
**Category:** Libraries\
**Created:** [October 25, 2018, 2:10pm UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867 "2018-10-25T14:10:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![seo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/seo/32/2034_2.png) [@seo](https://discourse.processing.org/u/seo)\
**Post date:** [October 25, 2018, 2:10pm UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/1 "2018-10-25T14:10:31Z")

</div>

hi!

I am using imageloader very well. But sometimes I get an error like this: Could not find a method to load: https: [//openclipart.org/download/279040/CigCardHoudanCock.svg](https://openclipart.org/download/279040/CigCardHoudanCock.svg).

Why is there an error? And even when there is no search result, NullPointerException will also appear. Is there any way to circumvent it?

Thanks…

---

<div class="post-metadata">

**Author:** ![seo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/seo/32/2034_2.png) [@seo](https://discourse.processing.org/u/seo)\
**Post date:** [October 25, 2018, 2:13pm UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/2 "2018-10-25T14:13:35Z")

</div>

and… sometimes… \<java.io.IOException: Server returned HTTP response code: 403 for URL\>

---

<div class="post-metadata">

**Author:** ![TheWizardBear](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/thewizardbear/32/3552_2.png) [@TheWizardBear](https://discourse.processing.org/u/TheWizardBear)\
**Post date:** [October 25, 2018, 8:02pm UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/3 "2018-10-25T20:02:12Z")

</div>

Can we see the code please?

P.S. You can edit posts, you know? 😛

---

<div class="post-metadata">

**Author:** ![seo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/seo/32/2034_2.png) [@seo](https://discourse.processing.org/u/seo)\
**Post date:** [October 26, 2018, 12:28am UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/4 "2018-10-26T00:28:12Z")

</div>

The same thing happens in the basic example.

```auto
import at.mukprojects.imageloader.*;
import at.mukprojects.imageloader.google.*;
import at.mukprojects.imageloader.image.*;

String apiKey = "MY API KEY";

ImageLoader loader;
ImageList list;
Image img;

void setup() {
  size(800, 450);

  loader = new GoogleLoader(this, apiKey);
  list = loader.start("sunset beach", true, 60 * 1000);
}

void draw() {
  if (img == null) {
    img = list.getRandom();
  } else {
    image(img.getImg(), 0, 0, width, height);
  }
}

void mousePressed() {
  img = list.getRandom();
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [October 30, 2018, 6:18pm UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/6 "2018-10-30T18:18:58Z")

</div>

> [@seo](#):
>
> ould not find a method to load: https: [//openclipart.org/download/279040/CigCardHoudanCock.svg](https://openclipart.org/download/279040/CigCardHoudanCock.svg)

An svg file is [Scalable Vector Graphics](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics). imageLoader doesn’t support that file format, so the file fails.

> [@seo](#):
>
> \<java.io.IOException: Server returned HTTP response code: 403 for URL\>

A [403 error](https://en.wikipedia.org/wiki/HTTP_403) is common to get if you pass an image path that points to a directory that is not viewable on the server. Viewing is forbidden; you are trying to load a bad url.

Often, 401 is “Show me your id first”, 404 is “Not found”, 403 is just “Nope.”

---

<div class="post-metadata">

**Author:** ![seo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/seo/32/2034_2.png) [@seo](https://discourse.processing.org/u/seo)\
**Post date:** [October 31, 2018, 2:28am UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/7 "2018-10-31T02:28:48Z")

</div>

Thank you. I created an error response code.

---

<div class="post-metadata">

**Author:** ![seo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/seo/32/2034_2.png) [@seo](https://discourse.processing.org/u/seo)\
**Post date:** [October 31, 2018, 2:30am UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/8 "2018-10-31T02:30:04Z")

</div>

The API key must be hidden.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 31, 2018, 3:40am UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/9 "2018-10-31T03:40:41Z")

</div>

> [@jeremydouglass](#):
>
> An svg file is [Scalable Vector Graphics](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics). imageLoader doesn’t support that file format, so the file fails.

yes, but

> **[Load and Display a Shape Illustration / Examples](https://www.processing.org/examples/loaddisplaysvg.html)**
>
> The loadShape() command is used to read simple SVG (Scalable Vector Graphics) files and OBJ (Object) files into a Processing sketch. This example loads an SVG file of a monster robot face and displays…

```auto
PShape bot;

void setup() {
  size(640, 360);
  // The file "bot1.svg" must be in the data folder
  // of the current sketch to load successfully
  bot = loadShape("https://openclipart.org/download/279040/CigCardHoudanCock.svg");
} 

void draw(){
  background(102);
  shape(bot, 110, 90, 100, 100); // Draw at coordinate (110, 90) at size 100 x 100
  shape(bot, 280, 40); // Draw at coordinate (280, 40) at the default size
}

```

works ( even slow for this very big SVG )

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [October 31, 2018, 2:51pm UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/10 "2018-10-31T14:51:27Z")

</div>

That is true.

I think the goal here is to use ImageLoader to interact with Google. Google sometimes returns svg files, which it did not use to do. ImageLoader passes them to PApplet.loadImage, here, e.g. here:

> <https://github.com/keshrath/ImageLoader/blob/master/src/at/mukprojects/imageloader/ImageLoader.java#L51-L57>

…which then throws an error, because PApplet.loadImage can’t handle svg:

> <https://github.com/processing/processing/blob/master/core%2Fsrc%2Fprocessing%2Fcore%2FPApplet.java#L5576-L5578>

I don’t think that ImageLoader can be changed to dynamically call loadShape because that would require rewriting the whole library – for example, ImageList isn’t set up to store PShapes.

Another approach would be to have ImageLoader throw the errors in a way that lets you recover a list of svg files as a separate output if you also want to manually load svg urls into shapes yourself – keeping in mind that some svgs will _still_ fail because loadShape can’t handle them.

---

<div class="post-metadata">

**Author:** ![jorgeeduardojonas](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jorgeeduardojonas](https://discourse.processing.org/u/jorgeeduardojonas)\
**Post date:** [September 11, 2020, 10:19am UTC](https://discourse.processing.org/t/imageloader-could-not-find-a-method-to-load/4867/11 "2020-09-11T10:19:31Z")

</div>

Hello! I’m having a similar issue, do you by any chance still have the error response code you wrote?

Many thanks in advance!
