GraphicsMagick getting “Stream yields empty buffer

2019-09-02 02:18发布

问题:

I am using GM for very simple thing: drawing a circle and put it in buffer. But after I check the code into Elastic Beanstalk, I am getting the "Stream yields empty buffer error" error. I am not sure why because it totally works on localhost.

Here is the code:

gm(200, 200, '#FF0000')
        .setFormat('png')
        .fill('#00FF00')
        .drawCircle( 50, 50, 60, 60 )
        .toBuffer(function( error, buffer )
        {
            if( error ) { res.send("error:"+error+" with content length:"+data.ContentLength);}
            res.writeHead(200, {'Content-Type': 'image/png' });
               res.end(buffer, 'binary');
        }

Thank you very much!

UPDATE I ran: gm convert -list format on both local and EC2 and found out that EC2 are missing PNG and JPEG support on it. Wondering how can I add the support. Any clues?

回答1:

Found the issue. Ran gm version command. Found out that PNG and JPEG are not supported. So turned out to be a dependency issue. Reinstall and solved it.