
Security News
Frontier AI Is Now Critical Infrastructure
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.
lambda-image
Advanced tools
Lambda Image is a simple image class to allow to easily manipulate images on AWS Lambda
If you wish to download an image from a url, you must install got as a package in your project.
If you wish to be able to load and save to s3, (and you aren't on aws lambda) you must install aws-sdk as a package in your project.
If you are testing locally, ensure you have imagemagick installed
const lambdaImage = require('lambda-image');
const image = await lambdaImage('/path/to/image.png');
const { height, width } = await image.getDimensions();
const resizedImage = await lambdaImage(await image.resize(512, 512));
await resizedImage.save({ bucket: 's3bucket', key: await resizeImage.getHashKey() });
Returns a image object. Must be called with await
loadInfo can be either a
{ bucket, key } for an s3 filedata:{contentType};base64 prefixIf a url is provided, you must provide the got library in your dependecies.
loadOptions is an object that can contain a profile of your aws credentials
const options = {
profile: 'default',
};
image.crop(width, height, gravity) Returns the buffer for the image when crop is appliedimage.getContentType() Get the mime typeimage.getDimensions() Get the dimensions in an object { height, width }image.getExt() Get the image extensionimage.getHash() Get the md5 hash of the imageimage.getHashKey() Get the save key based on the md5 hash 2C2A8686BFA31A2AE5F55A7F60009E14 => 2/C/2C2A8686BFA31A2AE5F55A7F60009E14.pngimage.getHeight() Get the height of the imageimage.getSize() Get the image file size in bytesimage.getType() Get the image extensionimage.getWidth() Get the width of the imageimage.identify() Get the data from imagemagick identifyimage.quality(percentage) Returns the buffer for the image when quality of percentage is appliedimage.resize(width, height) Returns the buffer for the image when resized to width / height - Does not cropimage.resizeAndCropCenter(width, height) Returns the buffer for the image when resized to width / height after croppingimage.rotate(degrees, color) Returns the buffer for the image when rotated. Color is used to fill in background color (defualts to transparent)image.save(saveInfo, saveOptions = loadOptions) Saves the image based on the saveInfo and saveOptionsimage.toBase64() Converts the image to base64 with the data:{contentType};base64 prefiximage.toBase64Binary() Converts the image to base64 without the data:{contentType};base64 prefiximage.toBuf() Converts the image to a buffersaveInfo can be either a
{ bucket, key } to save to an s3 bucketloadOptions is an object that can contain a profile of your aws credentials. This will default to saveOptions
const options = {
profile: 'default',
};
FAQs
Lambda Image Class for easy image manipulation on AWS Lambda
We found that lambda-image demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.