ImageLoader, Could not find a method to load

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.

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…

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

Can we see the code please?

P.S. You can edit posts, you know? :stuck_out_tongue:

The same thing happens in the basic example.

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();
}

An svg file is Scalable Vector Graphics. imageLoader doesn’t support that file format, so the file fails.

A 403 error 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.”

Thank you. I created an error response code.

The API key must be hidden.

yes, but

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 )

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:

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

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.

1 Like

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

Many thanks in advance!