-
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
Max size of image #1082
Comments
I think the max image size is 32,767 px in either dimension, but you're likely hitting some allocation failure for the format parser. What type of image is in the buffer (PNG, GIF, JPEG, SVG)? |
If I'm not mistaken it's a PNG image. |
I just successfully loaded a 1.45GB PNG (28,000 x 18,666 px). const fs = require("fs");
const {Image} = require("./index");
const buff = fs.readFileSync("big.png");
console.log(buff.byteLength);
const img = new Image();
img.src = buff;
console.log(img); Any more info you can provide? |
It's another canvas I'm turning in to an image not sure if that any different. |
The canvas buffer is "only" 24092988 bytes long :/ |
Can you post a short code example that reproduces it please? If the error is in some use of GLib then I might have missed it by trying to reproduce it on Windows. I can try on linux later. |
I'll see if I can create a sample that reproduces this that I'm able to share with you. |
That's a Cairo message/limitation that we can't do anything about. In the Cairo source I only see it raised if there is one dimension >32767 px (or <=0) though, which is larger than the dimensions you mentioned... |
I found a mistake I made trying to set the src to a PDF canvas buffer, but I'm getting "Error: out of memory" now. But when I look at the memory usages on my machine it's no more than 40% |
This code results in a "Error: out of memory" on my machine, which I don't get why as I got 16 gigs and the usages is no more than 40%. |
That means that the next attempted allocation failed, so if you have 60% of 16 GB and try to allocate 61% of 16 GB, you would get that error. (Depending on how you're looking at available memory you might also just be seeing used memory but not committed memory.) You're using a 64-bit build, right? I don't think there's anything we can do here to allow more memory to be used as it's a limitation of Cairo and/or your hardware. Some tips that might help reduce memory needs, looking at your example:
I hope I fixed this some time ago in #1003 (canvas 2.x) btw. If you're in 2.x and still seeing a need for it, let me know. |
The sample resembles the structure of the code I'm working on but base is a layer of image tiles from another process which I'm stitching together before rendering an overlay on top from SVG data. I working on parallelizing the processes as much as possible to cut down process time. Yes I'm running on 64bit I'll look into implementing some of your recommendations. |
Closing since I don't think there's anything we can do within node-canvas... |
Hi
Is there a max size on image?
I trying to set the src paramter of an image to a buffer containing an 28086x19866 px image and my node app just quits after that, no error no nothing.
-- Esben N.
The text was updated successfully, but these errors were encountered: