umkus / lambda-layer-sharp Goto Github PK
View Code? Open in Web Editor NEWAn AWS lambda layer with pre-built sharp node module optimised for minimal layer size
An AWS lambda layer with pre-built sharp node module optimised for minimal layer size
Thanks for the project, very helpful.
You've indicated that the current release (0.31.3) is compatible with both Lambda architectures (x86_64 and arm64).
It works for me with arm64 but fails for x86_64.
It will load image metadata OK but attempting to resize and image results in the following error:
2023-06-18T01:14:15.963Z 7428ffee-8520-41a5-8cbd-41cac6949031 ERROR Invoke Error
{
"errorType": "TypeError",
"errorMessage": "A boolean was expected",
"stack": [
"TypeError: A boolean was expected",
" at /opt/nodejs/node_modules/sharp/index.js:7200:15",
" at new Promise (<anonymous>)",
" at Sharp._pipeline (/opt/nodejs/node_modules/sharp/index.js:7199:14)",
" at Sharp.toBuffer (/opt/nodejs/node_modules/sharp/index.js:6001:15)",
" at Runtime.handler (/var/task/index.js:133056:71)"
]
}
Using webpack (5.88.2) with your latest release (https://github.com/Umkus/lambda-layer-sharp/releases/download/0.32.6/sharp-layer.zip).
I have created the layer using the zip referenced above and added to the Lambda that needs it. Source has been bundled with webpack.
Receiving the following: Runtime.ImportModuleError: Error: Cannot find module 'sharp'
.
I think it may have to do with the externals
property used by webpack. I have followed the instructions from the sharp documentation: https://sharp.pixelplumbing.com/install#aws-lambda. Any experience here?
Here is the full CloudWatch log error:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'sharp'\nRequire stack:\n- /var/task/EventIotTriggerPreTraffic.js\n- /var/runtime/index.mjs",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 'sharp'",
"Require stack:",
"- /var/task/EventIotTriggerPreTraffic.js",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:///var/runtime/index.mjs:1087:17)",
" at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
" at async start (file:///var/runtime/index.mjs:1282:23)",
" at async file:///var/runtime/index.mjs:1288:1"
]
}
Hi, can i get one that support gif
lovell/sharp#2012 (comment)
I follow this on my feed. Creating tags will notify me when there's a new version available.
Thank you!
Hi
Im trying to build it myself to use it as a layer, but during building i get the following warning.
WARNING in ./node_modules/sharp/lib/libvips.js 54:23-70Critical dependency: the request of a dependency is an expression.
Does it really contain the libvips library?
Hello there,
Thank you for creating this layer. I had a hard time figuring out Sharp to work with Lambda. I tried your prebuilt layer.
This is what I tried,
When I run the function I get the below error. I am not sure what I am doing wrong here.
{ "errorType": "Error", "errorMessage": "\nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-linux-x64.node'\nRequire stack:\n- /var/task/src/files/s3/compress.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js\n\nPossible solutions:\n- Install with the --verbose flag and look for errors: \"npm install --ignore-scripts=false --verbose sharp\"\n- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install" }
Hello, thanks for providing this repo.
I have hit a problem. I want to set the density
of a .tiff
file in a lambda. The code works perfectly when running locally using sharp
, but not in the lambda env. Example code that works/doesn't:
const printFileContent = await sharp(printFileName)
.toFormat('tiff', {
compression: 'none',
})
.withMetadata({
density: 300,
})
.toBuffer();
any ideas why this would work locally but not when using the layer? Other sharp functionality works (converting to .tiff
, setting compression, attaching .icc
color profiles etc). Thanks in advance.
I'm trying to use this lambda layer to compress heic images to jpeg. Does this allow for that?
Hi,
while trying to deploy the layer im getting the below error
An error occurred: SharpLambdaLayer - Could not unzip uploaded file. Please check your file, then try to upload again. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException;
I tried to download the version 0.32.6 and use it in my layer, but it got an error.
downgrading the zip to 0.32.1 worked fine. So maybe there is a problem with this build?
I'm using node18.x with X86_64. and deploying it with the sst example app here: https://github.com/sst/sst/tree/master/examples/bucket-image-resize
My problem is already solved, so I wont be able to follow this issue.
Feel free to close it when solved.
Hey thanks for this but I would like to know how we can make this compatible with other nodejs versions like 14,16 and 18
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.