Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask for update to lastest ImageMagick and Nodejs #51

Open
daoanhthanh opened this issue Nov 21, 2023 · 5 comments
Open

Ask for update to lastest ImageMagick and Nodejs #51

daoanhthanh opened this issue Nov 21, 2023 · 5 comments

Comments

@daoanhthanh
Copy link

The Nodejs v10 is no longer supported by AWS. Could you please update your layer to support node v20. I could not do it :((

@ersel
Copy link

ersel commented Nov 22, 2023

I have done this recently for Nodejs v20 and arm chipset.

You can download the layer.zip from the archive here.

https://github.com/CyprusCodes/imagemagick-aws-lambda-2/tree/master/archive

@daoanhthanh
Copy link
Author

daoanhthanh commented Nov 23, 2023

@ersel I used the lastest gm to handle image processing. However, the lambda function returns this error:

2023-11-23T02:26:41.739Z	51ec5d98-e696-4659-bcc1-3c34b15abf1c	INFO	beforeResize <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 48 00 48 00 00 ff e2 0c 58 49 43 43 5f 50 52 4f 46 49 4c 45 00 01 01 00 00 0c 48 4c 69 6e 6f 02 10 00 00 ... 849077 more bytes>
2023-11-23T02:26:54.111Z	51ec5d98-e696-4659-bcc1-3c34b15abf1c	INFO	afterResized <Buffer >
2023-11-23T02:26:54.133Z	51ec5d98-e696-4659-bcc1-3c34b15abf1c	INFO	toS3 <Buffer >
2023-11-23T02:26:54.190Z	51ec5d98-e696-4659-bcc1-3c34b15abf1c	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read properties of undefined (reading 'mime')","reason":{"errorType":"TypeError","errorMessage":"Cannot read properties of undefined (reading 'mime')","stack":["TypeError: Cannot read properties of undefined (reading 'mime')","    at toS3 (file:///var/task/services.js:88:28)","    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","    at async file:///var/task/index.js:7:3","    at async handler (file:///var/task/index.js:6:9)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read properties of undefined (reading 'mime')","    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)","    at process.emit (node:events:514:28)","    at emit (node:internal/process/promises:150:20)","    at processPromiseRejections (node:internal/process/promises:284:27)","    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}

This happens because the gm library could not interact with ImageMagick's API, therefore the resize function's output is null as you can see in the log above in the second row. I used lambda node20 for ARM and your layer only.

Here is my code for using GM:

const gm = require("gm").subClass({ imageMagick: "7+" });
const resize = async (imageArrayBuffer, width, height = undefined) => {
	console.log("beforeResize", imageArrayBuffer);
	return await gmToBuffer(gm(imageArrayBuffer).resize(width, height)).then(
		(resizedImage) => {
			console.log("afterResized", resizedImage);
			return resizedImage;
		}
	);
};
...

Do you have any ideas about why it happens, please?

@johnpc
Copy link

johnpc commented Mar 24, 2024

@ersel how do I use the zip file that you've shared?

@ersel
Copy link

ersel commented Mar 24, 2024

@johnpc upload the file as a Lambda Layer using the AWS dashboard

@johnpc
Copy link

johnpc commented Mar 24, 2024

Ah, I missed the part about how it requires arm. Is it possible to make an x86 version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants