Created
February 16, 2019 20:50
-
-
Save veelenga/1528c4cf9954e39bbb9e60f433b3d74f to your computer and use it in GitHub Desktop.
AWS HEIC to JPEG Converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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