Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
cannot loadImage() from URL

I try to loadImage() a file from random website to my sketch, but for some reason it doesn't work in lot of cases:

function preload() {

  img = loadImage("https://i.tpg.ua/news/news_20190724_103144_1563953504.jpg"); // <- this URL works fine

  // uncomment any of these lines to see the problem:

  //img = loadImage("https://breeze.ru/files/images/port_exmouth_3.jpg");
  //img = loadImage("https://www.ticketswhales.com/wp-content/uploads/2021/01/Whales-Watching9-1100x1100.jpg");
  //img = loadImage("https://i-foto-oboy.ru/pixes/ware/big/f03d7c2c05d2bbe348abd63e847a99c5.jpg");
  //img = loadImage("https://glazamidrona.ru/wa-data/public/shop/img/snimok-ekrana-2020-04-29-v-19.06.19.png");
  //img = loadImage("https://i.ytimg.com/vi/r-utuoM77zI/maxresdefault.jpg");

}

function setup() {
  createCanvas(300, 300);
  image(img, 0, 0, width, height);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.min.js"></script>

All images by links above can be viewed in browser or be downloaded, I don't understand what is the difference between them and why most of them can't be loaded in sketch.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

p5.js says: It looks like there was a problem loading your image. Try checking if the file path (https://www.ticketswhales.com/wp-content/uploads/2021/01/Whales-Watching9-1100x1100.jpg) is correct, hosting the file online, or running a local server.

You can't bypass CORS without proxy like https://cors-anywhere.herokuapp.com/corsdemo OR own server with right origin policy OR change browser settings on CORS issue.


access-control-allow-origin:

https://i.tpg.ua/news/news_20190724_103144_1563953504.jpg


Sec-Fetch-Mode: no-cors

Sec-Fetch-Site: same-origin:

https://breeze.ru/files/images/port_exmouth_3.jpg


https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy

https://developer.chrome.com/blog/referrer-policy-new-chrome-default/

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!