Image Stream End Event dose not Mean That Image has been Saved? #170

hustcer opened this Issue May 16, 2012 · 2 comments

2 participants


I have created a lot of images in a for loop, and using a counter to stat images have been saved on the stream end event, and if all the image output streams are ended, i will compress the folder, but I found that when the compressed zip ball was unzipped the images in it are just some chunks, which seemed to be unfinished. Is this a bug?

   var out  = fs.createWriteStream(uploadDir + resourceDir + '/images/' + className + '.png')
    , stream    = canvas.createPNGStream();

    stream.on('data', function(chunk){

    stream.on('end', function(){
        // out.end();
        // out.destroy();
        counter ++;
        if(counter === imgCount){
            console.log('Image Output Finish!');
            _compressFile(resourceDir, res);

        // console.log('Saved Png File:' + className + "counter: " + counter);

I found this problem in Mac OS (lion), but in Ubuntu it seemed to be ok. Any one know WHY?


Image stream end means that the image stream has ended. The out objects finish event means that the file is fully written to the disk. 👍

@LinusU LinusU closed this Feb 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment