PHP / Javascript / HTML5 canvas - loading external images
Ok, so I want:
- Take an external image
- Import it into the canvas object
- Compression
- Save
I have everything that works with local images, however trying to import external images into the canvas creates a security error.
Using PHP, I can create a copy of the external file locally:
file_put_contents("copy.jpg", file_get_contents("http://external.com/image.jpg"));
The problem is that external images can be quite large - up to 3MB and the canvas will be imported before the image is loaded.
Is there any PHP or Javascript code that waits until the file is fully loaded?
Or is there a better way to do this?
+3
source to share
3 answers