Skip to content

Instantly share code, notes, and snippets.

@veelenga
Created February 16, 2019 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veelenga/1528c4cf9954e39bbb9e60f433b3d74f to your computer and use it in GitHub Desktop.
Save veelenga/1528c4cf9954e39bbb9e60f433b3d74f to your computer and use it in GitHub Desktop.
AWS HEIC to JPEG Converter
const gm = require('gm').subClass({ imageMagick: true });
const root = process.env['LAMBDA_TASK_ROOT'];
const path = process.env['PATH'];
const libPath = process.env['PATH'];
// change the Lambda Runtime to use pre-built binary
process.env['PATH'] = `${root}/bin:${path}`;
process.env['LD_LIBRARY_PATH'] = `${root}/lib:${libPath}`;
// convert HEIC to JPEG
exports.handler = (event, context, callback) => {
let [ path ] = event.img.split('.');
gm(event.img).write(`${path}.jpeg`, (err) => console.error(err));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment