-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PNG with cHRM chunk fails to render #122
Comments
interesting! because neither should work actually haha, currently only local IO works for |
But I'm assigning a buffer to I'm sending request manually via I thought this was supposed to work? |
oh wow haha, fail on my part, i should have read the code. Yeah buffers should definitely work, if I have a minute I'll try and reproduce this |
Thanks, TJ! |
hmm definitely seems ok for the quick test I did: var Canvas = require('../')
, Image = Canvas.Image
, canvas = new Canvas(400, 400)
, ctx = canvas.getContext('2d')
, http = require('http')
, parse = require('url').parse
, fs = require('fs');
var url = parse('https://assets0.github.com/img/89d8e6624fb9153c40bd11ae7592a74e058d873e?repo=&url=http%3A%2F%2Fsphotos.ak.fbcdn.net%2Fhphotos-ak-snc3%2Fhs234.snc3%2F22173_446973930292_559060292_10921426_7238463_n.jpg&path=');
http.get({
path: url.pathname + url.search
, host: url.hostname
}, function(res){
var buf = '';
res.setEncoding('binary');
res.on('data', function(chunk){ buf += chunk });
res.on('end', function(){
var img = new Image;
img.src = new Buffer(buf, 'binary');
ctx.drawImage(img, 0, 0);
fs.writeFile('/tmp/tobi.png', canvas.toBuffer());
});
}); |
Yep, that works. But my test image still doesn't work when plugged into your test case :( It's almost as if something is wrong with an image, but I can't tell what.
It opens fine in the browser, and I can save and view it locally. It also draws on canvas in a browser perfectly:
Any ideas? |
FWIW, this isn't the only image that fails. We get similar problem with other images occasionally. |
hmmmm it could be a few things, tough call but perhaps my magic number stuff is off, I'll grab that image and see if I can figure out what's going on |
ah, it actually gets an onerror callback haha. I've been meaning to throw that when no error handler is present, the browser api is kinda weird IMO, but what browser APIs are not weird haha. I'll see if I can find what's not parsing correctly |
hmm when I request with curl or the browser I get the image, however with node I get a 403 and some xml |
getting this funky stderr from libpng:
|
We just found that all images that fail were processed via ImageMagick to have their white background removed. Might have something to do with it. Investigating further... |
seems to be here in |
I am having the same issue. I tried to run one of the examples and it didn't work. This codes: var fs = require("fs") fs.readFile(__dirname + '/teste.png', function(err, squid){ Throws the error: ctx.drawImage(img, 0, 0, img.width / 4, img.height / 4); Any solution? I am in a Mac OSX 10.6.8. Thanks, Giulian Drimba. |
Has anybody find a resolution for this issue? I can reproduce the problem when using the following code var Canvas = require('canvas') var url = parse('http://www.kaplaninternational.com/Images/01-Seattle-skyline_tcm7-15463.jpg'); http.get({
}); I get
Error: Image given has not completed loading Any help would be greatly appreciated! |
No..in my case, I decided to use https://github.com/hacksparrow/node-easyimage instead. |
@giuliandrimba Uhhh, ImageMagic is disgusting! All you can do is some cropping and that not even well. @gonzoramos Have you even tried to log your |
was there any resolution to this? i just upgraded to 1.0.0 and the exception is still being thrown every once in a while for a stray image. i'm trying to log the images to see if i can find a common thread between them, but i was hoping someone had found a systemic fix. thanks! |
I found that if I use the following pattern, things work... var img = new Image();
img.onload( function() {
// ... do things
} );
img.src = new Buffer ( data, 'binary'); |
This is still an issue for me. It's as though the onload is never called. I'm using a buffer with an svg and trying to convert it to a png. |
I got the same problem, I want to access RGB data of an image, is node-canvas the only option? |
I search for many solutions but no one works... anyone can correct on the source and release a possible package to use? |
I also got this problem ,when my image size is small, everything is ok, but it failed when the image size became large..... Could any one figure it out? |
+1 getting this for all images... |
It worked successfully with this code. (I used 204x204 jpg file) http.get(url, function (res) {
var buf = '';
res.setEncoding('binary');
res.on('data', function(chunk){ buf += chunk; });
res.on('end', function(){
var canvas = new Canvas();
var image = new Canvas.Image;
image.onload = function(){
console.log('onload');
};
image.onerror = function(err){
console.log(err);
};
image.src = new Buffer(buf, 'binary');
});
}); My experience:
You should check your libjpeg, libpng. Uninstall node-canvas, install them and reinstall node-canvas. I hope this works to you. |
was facing the same error and for some reason reinstalling node-canvas worked! |
@choyongjoon It works for me! thank you! |
The |
This works with Cairo 1.16.0 🎉 . |
Here's a simplified test case, where one image renders and another one fails (
url
vsurl2
). Both images open fine in a browser (and can be downloaded and viewed locally).Image fails with "Error: Image given has not completed loaded".
I'm not 100% sure if the problem is with node-canvas. Would appreciate any pointers!
The text was updated successfully, but these errors were encountered: