Automattic / Automattic/node-canvas

Canvas.pngStream Image File Cutoff

Open
#567 0 comments 0 reactions 0 assignees View on GitHub
Bug Needs more info
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.

![d41caba1af3849af8ac0dcc21384440a-email](https://cloud.githubusercontent.com/assets/130418/8220415/925aa66e-1520-11e5-9e17-17ce0343b5a2.jpg)

```
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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.