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

Lambda layer does not work #30

Closed
Cruaier opened this issue Apr 26, 2024 · 7 comments
Closed

Lambda layer does not work #30

Cruaier opened this issue Apr 26, 2024 · 7 comments

Comments

@Cruaier
Copy link

Cruaier commented Apr 26, 2024

Hi there,

I tried out the Lambda layer following your build script but I am getting an error running the example code of this repository:

{
  "errorType": "Error",
  "errorMessage": "Input buffer contains unsupported image format",
  "trace": [
    "Error: Input buffer contains unsupported image format",
    "    at Sharp.metadata (/opt/nodejs/node_modules/sharp/lib/input.js:486:17)",
    "    at getFileMetadata (/var/task/index.js:1351:40)",
    "    at Runtime.handler (/var/task/index.js:1377:26)",
    "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
  ]
}

The steps I did for the build were:

sam build --use-container --build-image public.ecr.aws/sam/build-nodejs20.x:latest - zip the build output and load it into a Lambda layer; create a Lambda function with the content of the examples layer and test it.
I have a very similar build script for building a Lambda layer which also doesn't work for me (see ticket lovell/sharp#4081).

Do you was able to test the Lambda layer with the latest versions?

@zoellner
Copy link
Owner

Yes, I am using the latest version in production.
Since the error message mentions an unsupported image format I'd need to have the original image file to be able to test

@Cruaier
Copy link
Author

Cruaier commented Apr 26, 2024

I used the test file you provided in this repository.
Are you willing to share your Lambda layer artifact with me?
I am attaching mine for reference if you want to have a look: https://we.tl/t-WGA5jgpGFc

@zoellner
Copy link
Owner

I can confirm that it does not actually work. My tests were running against an old version.

I thought it might be the missing x265 which I added in 4.1.0 but it still doesn't work. No idea why. vips 8.15.2 is compiled with libheif HEIC/AVIF load/save with libheif : YES (dynamic module: YES) and sharp detects the lib

sharp: Detected globally-installed libvips v8.15.2

sharp: Attempting to build from source via node-gyp
sharp: Found node-addon-api
sharp: Found node-gyp version 10.1.0

@Cruaier
Copy link
Author

Cruaier commented Apr 28, 2024

The compilation itself works; you can test it e.g. inside the build docker container without issues (both sharp and vips). I assume the issue is with the packaging. If I have more time I'll investigate further.

@Cruaier
Copy link
Author

Cruaier commented Apr 30, 2024

@zoellner I think the issue for you might be the same as in my script; the preset for libheif has to be changed during the compilation to "release-noplugins" in order to create a static build.

You can also have a look at my code for the sharp-heif layer here: https://github.com/Dobe-Solutions/sharp-heif-lambda-layer

zoellner added a commit that referenced this issue Apr 30, 2024
@zoellner
Copy link
Owner

Thank you. will give that a try

@zoellner
Copy link
Owner

Had to make a few more tweaks but seems to work now. Thanks again for debugging

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

2 participants