I'm working on an AWS Lambda application that needs to take a TIFF file and convert it to a PDF. I'm using ImageMagick exensively, so the easiest thing to do was: convert input.tif output.pdf. That works fine in my Mac environment, but fails in to convert to a true PDF in the Lambda environment.
The ImageMagick build on Lambda seems to not support PDFs. If I run convert -list format in the Lambda environment, there's no entry for PDF. Here's my test Lambda function:
const im = require('imagemagick');
const fs = require('fs');
exports.handler = (event, context, callback) => {
  var inputFileName = 'input.tif';
  var imagesPath = 'assets/images';
  var outputFile = '/tmp/output.pdf';
  var args = [
    imagesPath+'/'+inputFileName,
    '-format',
    'pdf',
    outputFile
  ];
  im.convert(args,
    function(err, stdout, stderr){
      if (err) throw err;
      console.log('stdout:', stdout);
      var imageRef = fs.readFileSync(outputFile);
      callback(null, {
        statusCode: 200,
        headers: {
          'Content-Type': 'application/pdf',
          'Content-Disposition': 'attachment; filename=output.pdf'
        },
        body: imageRef.toString('base64'),
        isBase64Encoded: true
      });
    });
}
When I run identify output.pdf (i.e. the downloaded file), the file is reported as a TIFF file:
/Users/myuser/Downloads/output.pdf TIFF 517x243 517x243+0+0 8-bit CMYK 1.1314MiB 0.000u 0:00.009
So ImageMagick seems to just be passing it through as a TIFF file.
I've tried using tiff2pdf - which is installed locally; not sure about Lambda - but that doesn't even work on my Mac. I get an error saying:
tiff2pdf: No support for /path/to/input.tif with 5 samples per pixel.