{"id":18772103,"url":"https://github.com/christianrich/aws-lambda-image-resizing","last_synced_at":"2026-04-18T19:32:57.589Z","repository":{"id":150404165,"uuid":"159585157","full_name":"ChristianRich/aws-lambda-image-resizing","owner":"ChristianRich","description":"AWS Lambda function to handle image resizing","archived":false,"fork":false,"pushed_at":"2018-12-13T00:19:12.000Z","size":89891,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T09:27:09.476Z","etag":null,"topics":["aws-lambda","aws-s3","javascript","nodejs","serverless","sharp"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChristianRich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-29T00:45:28.000Z","updated_at":"2018-12-13T00:19:14.000Z","dependencies_parsed_at":"2023-04-25T16:19:57.937Z","dependency_job_id":null,"html_url":"https://github.com/ChristianRich/aws-lambda-image-resizing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ChristianRich/aws-lambda-image-resizing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristianRich%2Faws-lambda-image-resizing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristianRich%2Faws-lambda-image-resizing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristianRich%2Faws-lambda-image-resizing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristianRich%2Faws-lambda-image-resizing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChristianRich","download_url":"https://codeload.github.com/ChristianRich/aws-lambda-image-resizing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristianRich%2Faws-lambda-image-resizing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","aws-s3","javascript","nodejs","serverless","sharp"],"created_at":"2024-11-07T19:27:46.416Z","updated_at":"2026-04-18T19:32:57.572Z","avatar_url":"https://github.com/ChristianRich.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Lambda image resizing using\nAWS Lambda function to handle image resizing using [npm sharp](https://www.npmjs.com/package/sharp).  \n\nAccepts an existing S3 resource URL, validates the source image, resizes it and save to another file in S3.\n\nSupports any number of images resized from a single source to output e.g fullsize, medium size and thumbnail.\n\n## Installation\n\n```\nnpm i\n```\n\n## Serverless config\nThe following env vars are required in `serverless.yaml`:  \n\n```\nS3_BUCKET_NAME: my-s3-bucket\nMAX_FILE_SIZE_MB: 10\nMAX_WIDTH_PIXELS: 10000\nMAX_HEIGHT_PIXELS: 10000\nALLOWED_IMAGE_TYPES: jpeg,jpg,png\n\n```\n## Build and deploy to AWS Lambda\n\nSetup AWS CLI and add your credentials:  \n[https://docs.aws.amazon.com/lambda/latest/dg/setup-awscli.html](https://docs.aws.amazon.com/lambda/latest/dg/setup-awscli.html)  \n\n\nThen bundle and deploy:\n```\nserverless webpack\nserverless deploy\n```\n\nOr using a specific AWS profile  \n```\nserverless deploy --aws-profile myProfileName\n```\n\n## Service end-points\n`POST /`  \nSample request:\n\n```json\n{  \n  \"data\":{  \n    \"attributes\":{  \n      \"input\":{  \n        \"key\":\"example.jpg\" // Existing file in the target S3 bucket\n      },\n      \"output\":{  \n        \"key\":\"my-resized-image\", // file extension is appended automatically\n        \"quality\":90\n      },\n      \"operations\":[  \n          {  \n          \"maxWidth\":1200, // Using automatic aspect calculation in order to maintain aspect ratio\n          \"tag\":\"fullsize\"\n        },\n        {  \n          \"width\":5000, // Using fixed width / height configuration\n          \"height\":5000,\n          \"tag\":\"thumbnail\"\n        },\n      ]\n    }\n  }\n}\n```\n\nSample response outputting the result of the operation:\n\n```json\n{  \n  \"data\":[  \n    {  \n      \"type\":\"image-processing-operation\",\n      \"attributes\":{  \n        \"url\":\"https://s3-ap-southeast-2.amazonaws.com/s3-target-bucket/2018/12/some-image-1200x900.jpg\",\n        \"key\":\"some-image-1200x900.jpg\",\n        \"prefix\":\"2018/12\",\n        \"region\":\"ap-southeast-2\",\n        \"baseUrl\":\"https://s3-ap-southeast-2.amazonaws.com\",\n        \"meta\":{  \n          \"processingTime\":\"1.52 sec\",\n          \"sizeReduction\":\"89.85%\",\n          \"tag\":\"fullsize\",\n          \"input\":{  \n            \"width\":4048,\n            \"height\":3036,\n            \"size\":\"5.29 MB\"\n          },\n          \"output\":{  \n            \"width\":1200,\n            \"height\":900,\n            \"size\":\"549.64 KB\"\n          }\n        }\n      }\n    },\n     {  \n      \"type\":\"image-processing-operation\",\n      \"attributes\":{  \n        \"url\":\"https://s3-ap-southeast-2.amazonaws.com/s3-target-bucket/2018/12/some-image-5000x5000.jpg\",\n        \"key\":\"some-image-5000x5000.jpg\",\n        \"prefix\":\"2018/12\",\n        \"region\":\"ap-southeast-2\",\n        \"baseUrl\":\"https://s3-ap-southeast-2.amazonaws.com\",\n        \"meta\":{  \n          \"processingTime\":\"0.58 sec\",\n          \"sizeReduction\":\"0.00%\",\n          \"tag\":\"thumbnail\",\n          \"input\":{  \n            \"width\":4048,\n            \"height\":3036,\n            \"size\":\"5.29 MB\"\n          },\n          \"output\":{  \n            \"width\":800,\n            \"height\":600,\n            \"size\":\"1.01 MB\"\n          }\n        }\n      }\n    }\n  ]\n}\n```\n\n`POST /getSignedUrl`  \nReturns a pre-signed S3 url valid for 5 minutes\n\n## Build npm Sharp for AWS Lambda runtime environment\nAWS Lambda requires a Linux x64 compatible installation of [npm sharp](https://www.npmjs.com/package/sharp) because the library during install uses C++ bindings and [node gyp](https://github.com/nodejs/node-gyp). Since C++ compiling is OS dependant the installation files are not portable which does not suit the workflow of Serverless where dependencies are packages on localhost and then deployed remotely.  \n\nThere are other workarounds for this, e.g a CI/CD pipeline using Docker, but for this intent and purpose we are building the deploy package locally using a Docker image pre-deployment.\n\nDetails here:  \n[https://github.com/ChristianRich/aws-lambda-image-resizing/tree/master/lambda-sharp](https://github.com/ChristianRich/aws-lambda-image-resizing/tree/master/lambda-sharp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristianrich%2Faws-lambda-image-resizing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristianrich%2Faws-lambda-image-resizing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristianrich%2Faws-lambda-image-resizing/lists"}