Automattic / Automattic/node-canvas
Canvas.pngStream Image File Cutoff
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
I'm generating some images on my server. But for some unknown reason, a few random images get cut off. Any idea why this would happen. No errors are generated. Also, the image size is approx 1440x900.

```
function saveImage(canvas, complete) {
var tempImagePath = path.join(os.tmpdir(), uuid.v4() + '.png');
var out = fs.createWriteStream(tempImagePath);
var stream = canvas.pngStream();
stream.on('data', function(chunk){
out.write(chunk);
});
stream.on('error', function(err) {
console.error(err);
return complete(err);
});
stream.on('end', function(){
return complete(null, tempImagePath);
});
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the saveImage function and the canvas.pngStream() call shown in the report. Reproduce the intermittent cutoff with a 1440x900 image while checking the stream data, error, and end events and the output file. Done means identifying the cause and confirming that generated PNG files are complete without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100