Can I upload an image to the web?

Ok this isn’t a question about the code itself. In processing examples there’s one where they download an image from the internet and display it. My question is “is there a website that I can upload an image and use it’s link in my code?”

1 Like

You mean uploading by code? Or just upload it to a cloud like for instance Drive, where you can share the link and use it to download?

Not uploading by code. A website that I can manually upload pictures and use the picture link in my code. Upload manually and manually get a link that I can use in my code. Google drive doesn’t seem to work.

Of cours it works. After uploading your file you search for the uploaded file and click on the three dots where you can choose “share”. The link will be copied to your clipboard.

Sorry it took so long but here’s the code… the picture is a game character and to save space i wanted to load from the internet… the code returns an error “could not find a method to load ‘link’” any idea on a good website? Google drive crashes.

/**
 * Loading Images. 
 * 
 * Processing applications can load images from the network. 
 * 
 */

PImage img;

void setup() {
  size(640, 360);
  img = loadImage("https://drive.google.com/open?id=1dda0l4N2eWjT_tSlMooI53NV3j8LrkNW");
  noLoop();
}

void draw() {
  background(0);
  if (img != null) {
    for (int i = 0; i < 5; i++) {
      image(img, 0, img.height * i);
    }
  }
}
2 Likes

Hi,

I think you need a direct link to your image like "https://url_to_your_img.png".
I don’t know if it’s possible with Google Drive but you can use other image hosting websites like Imgur, Flickr, tinyPic or DropBox…

2 Likes

I have tried it with DropBox also.
Both of them use java script for transfer.
Even if you try to download a text with loadStrings() it will give you an output. But it’s java script.
If you download a “clean file” it will work.
Try

String[] lines = loadStrings("https://www.w3.org/TR/PNG/iso_8859-1.txt"); 
  println("there are " + lines.length + " lines"); 
  for (int i = 0; i < lines.length; i++) { 
    println(lines[i]);
  }

So I think you have to have it stored on own domain.

We never give up!!
I found a way.
Simply open the link in a browser, then click on image and choose “open image in new guide”. Then copy that link and it will work.

Edit: sigh, not for drive only for regular web site.

I managed it with an image that I stored on Pinterest with the method I described previously.

PImage img; 

void setup() { 
  size(250, 200); 
  img = loadImage("https://i.pinimg.com/236x/d9/63/aa/d963aa82a6b11b236543d0a3a0842e50.jpg"); 
  image(img, 0, 0);
}
2 Likes

Yay pininterest works! THANK you so much! I can save so much more space with this!

Hi, mikeren, welcome to the community.