-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Image given has not completed loading #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@visionmedia Can you please look after this issue. |
This issue affects me too. The code from Stracing the application show that the image is really not loaded (only 4096 bytes are read before the error message is printed). I will try to investigate it as well. Thanks ! |
Well, installing |
still got the same message :( /Users/jiguang/www/node/api.js:24 |
I was having this problem. I installed libjpeg (used 'brew install libjpeg' on osx). And it worked! |
I had the same issue for Ubuntu 12.04 LTS. Solution was to remove canvas, uninstall libjpeg-dev, libjpeg62-dev; install libjpeg8-dev; install canvas again. |
I'm experiencing this issue on smartOS as well. We don't have access to as many jpeg libraries as well.. This is a bummer |
Experiencing this too on OSX. Tried brew install libjpeg. No go for me. node-canvas V1.1.6 |
Me too . Can't load image. |
Me too.
Error: Image given has not completed loading |
I'm on OS-X as well and I followed the extra steps in the Windows installation. |
I tried @dzeikei trick on |
I've been able to dodge this issue using readFileSync() method instead of readFile()/img.onload |
For everybody on this ticket and for all those who will arrive in the future, please note that this error message MAY occur because you are attempting to load an image type that canvas does not support - probably due to a limited cairo build. You can verify this by trying to load a PNG instead which is typically supported. It is not clear why loading an unsupported image type results in this error message. |
Having the same issue to load jpg images. Tried installing libjpeg through brew still no luck. Works for PNG images and not for JPG images |
I was having this same problem, and the solution given by yhostc discussed in this issue ended up solving it:
|
@redspider How can we add JPEG support for node-canvas? |
@tomerb15 node-canvas doesn't care about image types, if I recall correctly it is cairo that cares (cairo is a dependency). You have to make sure your cairo build has JPEG enabled. I can't help you with that though. |
I was having the issue every time when I tried to render the PNG image below onto the canvas. I noticed that the rendering worked fine for other PNG images. So I used a hex editor (http://entropymine.com/jason/tweakpng/) to see what is different about the file. The obvious difference was the header: I removed the ancillary tEXt chunk, saved the file and re-rendered without any errors. This fixed the issue for me. There might me other chunks that confuse canvas when rendering. It would be really nice to have some basic data cleansing there to save us fiddling around with binary formats. |
I'm having the same problem even when I use readFileSync. My OS is Windows 10, and I've installed node-canvas as guided, and somehow it always fails with |
@redspider the reason of getting this error message is that when we try to use(draw) the image, it's actually not completed loaded yet. If you add a handler on img.onerror you will see this error instead: "Error: error while reading from input stream". And we should stop processing right there. |
I was getting this as well which was weird because I was sure the image was loaded before setting the data. But as mentioned above setting an It said "Out of memory" but it clearly wasn't. The issue ended up being a sRGB color profile that libpng didn't like. Stripping that fixed my issue. (in case anyone is ending up here from a google search like I did) In my case it was |
I'm running into this on two Windows 7 machines and a Windows 10 machine. The image files are normal JPGs, and the same code with the same images works great on macOS. |
As others have found, it looks like when following the install instructions for Windows (installing libjpgturbo), Cairo gets built without JPG support. The same code works fine if you work with PNGs. So... maybe it's just a documentation issue? |
There are a few different issues in this thread. @endquote and @jshin49 JPEG support for Windows is PR #841 and isn't merged yet (but is functional if you want to use his fork). I'm not sure exactly what you're doing without more context, but that is likely what you're hitting. (And you're right, the install wiki has been updated already, even though code hasn't been merged yet!) @yeldarby That's interesting and I think merits a new issue. The only other issue I see for color profiles is #725, which isn't what you've described. A lot of the other reports I think are from building node-canvas without libjpeg support (at least three different posters). For debian/ubuntu this means having libjpeg-dev (or a variant), for MacOS see the wiki instructions https://github.com/Automattic/node-canvas/wiki/Installation:-Mac-OS-X#having-trouble-with-gif-or-jpegs. For windows, as above, that means using the fork in #841 or waiting for that to be merged. Finally, a lot of this is better described in #486 ("not completed loading" is misleading) -- this error message occurs in a variety of situations unrelated to image loading: in addition to having a build without JPEG support, it apparently happens specifically for some color profiles (#289 (comment)) and unhandled PNG header chunks (#289 (comment)). |
Closing per above. |
Error:
Error: Image given has not completed loading
at /home/f-user/passport-facebook/examples/login/app.js:315:17
at fs.readFile (fs.js:176:14)
at Object.oncomplete (fs.js:297:15)
Code:
var canvas = new Canvas(650, 650)
, ctx = canvas.getContext('2d');
fs.readFile(__dirname + '/public/resimg/1.jpg', function(err, squid){
if (err) throw err;
img = new Canvas.Image;
img.src = squid;
img.onload = function(){
console.log("ian here in onload");
ctx.drawImage(img, 0, 0, img.width / 4, img.height / 4);
}
});
I have seen similar issues here, they mentioned to use "img.onload" in case we get this error "Image given has not completed loading"
But img.onload is not getting fired in my case.
May i know how to fix for this issue.
Thanks
The text was updated successfully, but these errors were encountered: