eivindfjeldstad / imagemagick-stream

Streaming Imagemagick API

Repository from Github https://github.comeivindfjeldstad/imagemagick-streamRepository from Github https://github.comeivindfjeldstad/imagemagick-stream

pipe breaks?

madshobye opened this issue · comments

I have a weird issue which I assume has something to do with imagemagick-stream (correct me if I am wrong). When converting multiple images it looks like the pipe breaks. The images are resized but are cut. I assume this has something to do with an over load on a stream (either imagemagick or fs). I am using node-gallery which uses this npm module.

The code that initiates the write stream can be found here:

https://github.com/cianclarke/node-gallery/blob/master/lib/middleware.js

I would be grateful for any pointers on how to debug or somebody who have had similar issues.

screen shot 2015-12-01 at 13 13 24

what end-type event are you listening to?

hey this is the code - as in the link:

// No result, create a write stream so we don't have to reize this image again
    cacheWritePath = path.join('/tmp', cachedResizedKey);
    cacheWriteStream = fs.createWriteStream(cacheWritePath);



    resizer = im().resize(dimensions).quality(40);
    resizer.on('error', function(err){
      return common.error(req, res, next, 500, 'Error in IM/GM converting file', err);
    });

    var resizestream = fstream.pipe(resizer);

    // Pipe to our tmp cache file, so we can use this in future
    resizestream.pipe(cacheWriteStream);
    cache.put(cachedResizedKey, cacheWritePath);

    // Also stream the resized result back to the requestee
    return resizestream.pipe(res);

I think i managed to solve it by updating to the latest imagemagick version.

ah, sorry didn't see that. I can't reproduce this, so it's very hard to do something without a failing test case. did it happen with all images or just a certain type/size?

btw, node-gallery is using an old version of imagemagick-stream. I think a similar bug was squashed somewhere around version 2, so maybe switching to the latest version will work. closing this for now.