Skip to content

Handling errors in stream mode #256

@rimassa

Description

@rimassa

Hello!

Suppose the following image operation:
var stream = gm('piano.png').crop(100, 100, 0, 0).stream('jpg')
How can I be notified of processing errors (such as if "piano.png" couldn't be opened)?

I've tried the alternative:
gm('piano.png').crop(100, 100, 0, 0).stream('jpg', function (err, stdout, stderr) {...})
Even in "piano.png" doesn't exists, the err parameter in the callback is null (that is expected).
If I attach a data event listener on stream stderr, I'm able to receive error messages - and detect processing errors.
But I've tried with a PNG file (http://www.iphonestheme.com/uploads/allimg/130206/1-1302061353440-L.png), and although the image was successfully processed, I still got some warnings coming from the stderr stream:

convert: iCCP: known incorrect sRGB profile `/Users/rgermano/iG/workspaces/iglr-app/test/resources/img-validator/piano_600x1636.png' @ warning/png.c/MagickPNGWarningHandler/1830.

Is there an approach using streams to catch processing errors only (not warnings)?

Thanks!
Ricardo

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions