eivindfjeldstad / imagemagick-stream

Streaming Imagemagick API
MIT License
92 stars 23 forks source link

'finish' event emitted too early. Output file size is zero. #16

Closed connyhald closed 9 years ago

connyhald commented 9 years ago

If we use a bigger input file, by the time the 'finish' event is emitted the output file is still emtpy.

I've changed the tests to check for file size > 0 and added a bigger test image. Please have a look:

https://github.com/connyhald/imagemagick-stream/commit/d73e1fd3e1192d6e16005ad463ec9663de0262e4

With that change all 3 test fail.

connyhald commented 9 years ago

However: Listening to 'close' on the file output stream seems to work in some cases, but not all. E.g. it is working with

var img = im()
    .thumbnail('160x90^')
    .gravity('center')
    .quality(85);

But not with

var img = im();

In the latter case, the 'close' event is never fired.

eivindfjeldstad commented 9 years ago

What version of Node is this?

connyhald commented 9 years ago

Node v0.10.36 ImageMagick 6.8.8-10 Q16 x86_64 2015-03-10

eivindfjeldstad commented 9 years ago

I've updated the tests and added a note to the readme. We should listen to the finish event on the write stream instead. Released as 3.0.0

connyhald commented 9 years ago

Thanks a lot!