How to fix Unhandled rejection Error: Could not execute GraphicsMagick/ImageMagick in AWS LAMBDA (NodeJS)
Unhandled rejection Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%p" "/tmp/temp.pdf" this most likely means the gm/convert binaries can't be found
I have tried everything mentioned in similar questions. This is my first lambda function and I am stuck. Please find below how I am adding gm into my lambda function index.js
// dependencies
var AWS = require('aws-sdk');
var simpleParser = require('mailparser').simpleParser;
const gm = require('gm').subclass({ imageMagick : true});
var fs = require("fs");
let PDF2Pic = require('pdf2pic').default
let converter = new PDF2Pic({
density: 100, // output pixels per inch
savename: "/tmp/temp", // output file location
format: "jpg" // output size in pixels
});
// by default the first page of the pdf will be converted
// to image
converter.convert("/tmp/temp.pdf")
.then(resolve => {
console.log("image converted successfully")
var contents = fs.readFileSync('/tmp/temp.jpg', 'utf8');
console.log(contents);
});
Executing this gives error :
converter.convert
aws-lambda imagemagick
|
show 2 more comments
Unhandled rejection Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%p" "/tmp/temp.pdf" this most likely means the gm/convert binaries can't be found
I have tried everything mentioned in similar questions. This is my first lambda function and I am stuck. Please find below how I am adding gm into my lambda function index.js
// dependencies
var AWS = require('aws-sdk');
var simpleParser = require('mailparser').simpleParser;
const gm = require('gm').subclass({ imageMagick : true});
var fs = require("fs");
let PDF2Pic = require('pdf2pic').default
let converter = new PDF2Pic({
density: 100, // output pixels per inch
savename: "/tmp/temp", // output file location
format: "jpg" // output size in pixels
});
// by default the first page of the pdf will be converted
// to image
converter.convert("/tmp/temp.pdf")
.then(resolve => {
console.log("image converted successfully")
var contents = fs.readFileSync('/tmp/temp.jpg', 'utf8');
console.log(contents);
});
Executing this gives error :
converter.convert
aws-lambda imagemagick
1
Which line is giving the error, is it theconst gm
line? For reference, here is a tutorial that uses ImageMagick: Tutorial: Using AWS Lambda with Amazon S3 - AWS Lambda
– John Rotenstein
Jan 1 at 22:09
using exactly the same. It is working on local ubuntu machine. But on lambda it is unable to find the binaries and give above issue. At first it gave the same issue on local and I ransudo install imagemagick
and it was fixed.
– Osama Goraya
Jan 1 at 22:12
Is this question able to help you?
– Maurice
Jan 1 at 23:41
yes already tried that but its too complicated for me. I don't know that where to run the commands as lambda is serverless and where to find serverless.yml file.
– Osama Goraya
Jan 2 at 8:46
Hi Osama. Please liaise with editors before performing a summary roll-back. I have downvoted as this is not acceptable behaviour for a new user on Stack Overflow. I will restore my version shortly, as begging is not an appropriate way of addressing volunteers.
– halfer
Jan 2 at 8:49
|
show 2 more comments
Unhandled rejection Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%p" "/tmp/temp.pdf" this most likely means the gm/convert binaries can't be found
I have tried everything mentioned in similar questions. This is my first lambda function and I am stuck. Please find below how I am adding gm into my lambda function index.js
// dependencies
var AWS = require('aws-sdk');
var simpleParser = require('mailparser').simpleParser;
const gm = require('gm').subclass({ imageMagick : true});
var fs = require("fs");
let PDF2Pic = require('pdf2pic').default
let converter = new PDF2Pic({
density: 100, // output pixels per inch
savename: "/tmp/temp", // output file location
format: "jpg" // output size in pixels
});
// by default the first page of the pdf will be converted
// to image
converter.convert("/tmp/temp.pdf")
.then(resolve => {
console.log("image converted successfully")
var contents = fs.readFileSync('/tmp/temp.jpg', 'utf8');
console.log(contents);
});
Executing this gives error :
converter.convert
aws-lambda imagemagick
Unhandled rejection Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%p" "/tmp/temp.pdf" this most likely means the gm/convert binaries can't be found
I have tried everything mentioned in similar questions. This is my first lambda function and I am stuck. Please find below how I am adding gm into my lambda function index.js
// dependencies
var AWS = require('aws-sdk');
var simpleParser = require('mailparser').simpleParser;
const gm = require('gm').subclass({ imageMagick : true});
var fs = require("fs");
let PDF2Pic = require('pdf2pic').default
let converter = new PDF2Pic({
density: 100, // output pixels per inch
savename: "/tmp/temp", // output file location
format: "jpg" // output size in pixels
});
// by default the first page of the pdf will be converted
// to image
converter.convert("/tmp/temp.pdf")
.then(resolve => {
console.log("image converted successfully")
var contents = fs.readFileSync('/tmp/temp.jpg', 'utf8');
console.log(contents);
});
Executing this gives error :
converter.convert
aws-lambda imagemagick
aws-lambda imagemagick
edited Jan 2 at 8:57
halfer
14.6k758113
14.6k758113
asked Jan 1 at 21:25
Osama GorayaOsama Goraya
12
12
1
Which line is giving the error, is it theconst gm
line? For reference, here is a tutorial that uses ImageMagick: Tutorial: Using AWS Lambda with Amazon S3 - AWS Lambda
– John Rotenstein
Jan 1 at 22:09
using exactly the same. It is working on local ubuntu machine. But on lambda it is unable to find the binaries and give above issue. At first it gave the same issue on local and I ransudo install imagemagick
and it was fixed.
– Osama Goraya
Jan 1 at 22:12
Is this question able to help you?
– Maurice
Jan 1 at 23:41
yes already tried that but its too complicated for me. I don't know that where to run the commands as lambda is serverless and where to find serverless.yml file.
– Osama Goraya
Jan 2 at 8:46
Hi Osama. Please liaise with editors before performing a summary roll-back. I have downvoted as this is not acceptable behaviour for a new user on Stack Overflow. I will restore my version shortly, as begging is not an appropriate way of addressing volunteers.
– halfer
Jan 2 at 8:49
|
show 2 more comments
1
Which line is giving the error, is it theconst gm
line? For reference, here is a tutorial that uses ImageMagick: Tutorial: Using AWS Lambda with Amazon S3 - AWS Lambda
– John Rotenstein
Jan 1 at 22:09
using exactly the same. It is working on local ubuntu machine. But on lambda it is unable to find the binaries and give above issue. At first it gave the same issue on local and I ransudo install imagemagick
and it was fixed.
– Osama Goraya
Jan 1 at 22:12
Is this question able to help you?
– Maurice
Jan 1 at 23:41
yes already tried that but its too complicated for me. I don't know that where to run the commands as lambda is serverless and where to find serverless.yml file.
– Osama Goraya
Jan 2 at 8:46
Hi Osama. Please liaise with editors before performing a summary roll-back. I have downvoted as this is not acceptable behaviour for a new user on Stack Overflow. I will restore my version shortly, as begging is not an appropriate way of addressing volunteers.
– halfer
Jan 2 at 8:49
1
1
Which line is giving the error, is it the
const gm
line? For reference, here is a tutorial that uses ImageMagick: Tutorial: Using AWS Lambda with Amazon S3 - AWS Lambda– John Rotenstein
Jan 1 at 22:09
Which line is giving the error, is it the
const gm
line? For reference, here is a tutorial that uses ImageMagick: Tutorial: Using AWS Lambda with Amazon S3 - AWS Lambda– John Rotenstein
Jan 1 at 22:09
using exactly the same. It is working on local ubuntu machine. But on lambda it is unable to find the binaries and give above issue. At first it gave the same issue on local and I ran
sudo install imagemagick
and it was fixed.– Osama Goraya
Jan 1 at 22:12
using exactly the same. It is working on local ubuntu machine. But on lambda it is unable to find the binaries and give above issue. At first it gave the same issue on local and I ran
sudo install imagemagick
and it was fixed.– Osama Goraya
Jan 1 at 22:12
Is this question able to help you?
– Maurice
Jan 1 at 23:41
Is this question able to help you?
– Maurice
Jan 1 at 23:41
yes already tried that but its too complicated for me. I don't know that where to run the commands as lambda is serverless and where to find serverless.yml file.
– Osama Goraya
Jan 2 at 8:46
yes already tried that but its too complicated for me. I don't know that where to run the commands as lambda is serverless and where to find serverless.yml file.
– Osama Goraya
Jan 2 at 8:46
Hi Osama. Please liaise with editors before performing a summary roll-back. I have downvoted as this is not acceptable behaviour for a new user on Stack Overflow. I will restore my version shortly, as begging is not an appropriate way of addressing volunteers.
– halfer
Jan 2 at 8:49
Hi Osama. Please liaise with editors before performing a summary roll-back. I have downvoted as this is not acceptable behaviour for a new user on Stack Overflow. I will restore my version shortly, as begging is not an appropriate way of addressing volunteers.
– halfer
Jan 2 at 8:49
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999053%2fhow-to-fix-unhandled-rejection-error-could-not-execute-graphicsmagick-imagemagi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999053%2fhow-to-fix-unhandled-rejection-error-could-not-execute-graphicsmagick-imagemagi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Which line is giving the error, is it the
const gm
line? For reference, here is a tutorial that uses ImageMagick: Tutorial: Using AWS Lambda with Amazon S3 - AWS Lambda– John Rotenstein
Jan 1 at 22:09
using exactly the same. It is working on local ubuntu machine. But on lambda it is unable to find the binaries and give above issue. At first it gave the same issue on local and I ran
sudo install imagemagick
and it was fixed.– Osama Goraya
Jan 1 at 22:12
Is this question able to help you?
– Maurice
Jan 1 at 23:41
yes already tried that but its too complicated for me. I don't know that where to run the commands as lambda is serverless and where to find serverless.yml file.
– Osama Goraya
Jan 2 at 8:46
Hi Osama. Please liaise with editors before performing a summary roll-back. I have downvoted as this is not acceptable behaviour for a new user on Stack Overflow. I will restore my version shortly, as begging is not an appropriate way of addressing volunteers.
– halfer
Jan 2 at 8:49