I am using the gm package for Node.js along with the default ImageMagick installation that is available on AWS Lambda.  
const gm = require('gm').subClass({ imageMagick: true });
For some reason, the resize functionality fails for certain images.
I created an EC2 instance with Amazon Linux AMI (ami-hvm-2016.03.3.x86_64-gp2).
I installed the (old) 6.x version of ImageMagick that is available from yum.  When I run my script with that install on the EC2 instance, it reproduces the failure I see when the code runs on Lambda, confirming it is something with this version of IM that is causing the failure.
If I install GraphicsMagick with sudo yum install GraphicsMagick.  This allows my script to perform the resizes without error.
const gm = require('gm').subClass({ imageMagick: false });
However, I'm not sure how to bundle this in my deploy with serverless.  If I install GraphicsMagick to the same folder as the script with sudo yum --installroot=/var/task install GraphicsMagick, and run my script using this require statement instead:
const gm = require('gm').subClass({ imageMagick: false, appPath: './usr/bin/' });
The resizes work when I run my script on the EC2 instance.  But when I deploy with serverless, and the script runs in Lambda, the executable appears to be broken.  gm fails with the following error on a call to gm(buffer).size(/*...*/).
could not get the image size: ERR: 
{"code":"EPIPE","errno":"EPIPE","syscall":"write"}
How can I build a version of ImageMagick or GraphicsMagick that can be deployed with serverless?

