{"id":13577483,"url":"https://github.com/nicholasgubbins/Serverless-Image-Resizer","last_synced_at":"2025-04-05T12:30:21.599Z","repository":{"id":41463446,"uuid":"99590290","full_name":"nicholasgubbins/Serverless-Image-Resizer","owner":"nicholasgubbins","description":"Serverless image resizer like imgix on API Gateway \u0026 Lambda","archived":false,"fork":false,"pushed_at":"2018-08-03T01:03:26.000Z","size":37,"stargazers_count":58,"open_issues_count":5,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-23T08:55:41.882Z","etag":null,"topics":["aws-lambda","nodejs","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicholasgubbins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-07T15:03:41.000Z","updated_at":"2023-12-24T06:27:32.000Z","dependencies_parsed_at":"2022-09-04T23:14:21.113Z","dependency_job_id":null,"html_url":"https://github.com/nicholasgubbins/Serverless-Image-Resizer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasgubbins%2FServerless-Image-Resizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasgubbins%2FServerless-Image-Resizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasgubbins%2FServerless-Image-Resizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasgubbins%2FServerless-Image-Resizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicholasgubbins","download_url":"https://codeload.github.com/nicholasgubbins/Serverless-Image-Resizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266562,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","nodejs","serverless"],"created_at":"2024-08-01T15:01:21.843Z","updated_at":"2025-04-05T12:30:21.202Z","avatar_url":"https://github.com/nicholasgubbins.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"Serverless-Image-Resizer\n========================\n[![Build Status][travis-image]][travis-url] [![dependencies Status][david-dep-image]][david-dep-url] [![devDependencies Status][david-devDep-image]][david-devDep-url] [![NPM version][npm-image]][npm-url] [![Twitter URL][twitter-image]][twitter-url]\n\nServerless-Image-Resizer is an image processing service that runs on AWS Lambda and S3.\n\n# Summary\n\nPut simply, Serverless-Image-Resizer works by requesting an image file from S3 and applying image\nprocessing functions to that image. Image processing functions are sent as query parameters in the\nrequest URL. Serverless-Image-Resizer first checks to see if the requested image (including effects)\nis stored in S3. If it is, then the cached version is returned. If it is not, then the\nprocessing functions are applied to the original image, and the resulting image is cached in S3 and\nsent back to the requester.\n\n## Example\n\nThe original image on the left has been vertically resized to 300 px and has had a blur of radius 0\nand sigma 3 applied to create the image on the right. The URL to perform this effect would be\n`https://API-URL.com/path/to/image.jpg?h=300\u0026b=0x3`.\n\n| Original | Edited |\n| --- | --- |\n| \u003cimg src=\"https://user-images.githubusercontent.com/2160046/29154251-faddecb4-7d47-11e7-8f75-e76085215146.jpg\"\u003e | \u003cimg src=\"https://user-images.githubusercontent.com/2160046/29154255-fe61f7cc-7d47-11e7-96f4-da46241e143b.jpg\"\u003e|\n\n# Setup\n\n## AWS and Serverless\n\nThis project relies on AWS + The [Serverless Framework](https://github.com/serverless/serverless)\nto deploy and manage your service. If it is not already, install serverless globally:\n\n```sh\n$ npm install -g serverless\n```\n\nYou will need an AWS account to deploy this service. If you do not already have one, sign up at\nhttps://aws.amazon.com\n\nYou will need AWS credentials to programmatically deploy your service from the commandline. Follow\nthe [Serverless AWS Credentials documentation](https://serverless.com/framework/docs/providers/aws/guide/credentials/)\nto get setup.\n\n## Code\n\nThere are two ways to get the project code, choose from one of the options:\n1. Clone the project and deploy from that project directory\n2. npm install the module and incorporate it into your own project\n\n### Clone\n\n```sh\n$ git clone https://github.com/nicholasgubbins/Serverless-Image-Resizer.git \u0026\u0026 cd Serverless-Image-Resizer\n$ git checkout $(git describe --tags `git rev-list --tags --max-count=1`) # checkout latest release\n$ npm i # or $ yarn\n```\n\n### npm\n\nIn your project directory, npm install the node module and the browserify serverless plugin:\n\n```sh\n$ npm install --save serverless-image-resizer\n$ npm install --save-dev serverless-plugin-browserify\n```\n\nYou can change where the function handlers live by editing `functions.FUNCTION_NAME.handler` in\n`serverless.yml`, but using the paths that are there now, you would use `serverless-image-resizer`\nby creating the files below:\n\n```js\n// in functions/resizeImage/index.js\nconst { resizeImage } = require('serverless-image-resizer');\n\nmodule.exports.handler = resizeImage.handler;\n\n\n// in functions/getImage/index.js\nconst { getImage } = require('serverless-image-resizer');\n\nmodule.exports.handler = getImage.handler;\n```\n\nYou will also need to copy [`serverless.yml`](https://raw.githubusercontent.com/nicholasgubbins/Serverless-Image-Resizer/master/serverless.yml)\nto the top level of your project directory.\n\n## Rename the AWS Region and S3 bucket\n\nIn `serverless.yml` change `provider.region` to the AWS Region your S3 bucket exists in, and where\nyou want your Lambda Function and API Gateway endpoints to exist. Also change\n`provider.environment.BUCKET` to be the name of your S3 bucket.\n\n## Deploy the service\n\nUsing serverless, deploy the service from the top level of the project:\n\n```sh\n$ sls deploy\n```\n\n## API Gateway Binary Support\n\nCurrently, there is no way to configure Binary Support using serverless (related [serverless issue](https://github.com/serverless/serverless/issues/2797)).\nFor now we can set this manually using the AWS Console:\n1. Open the AWS Console\n2. Click the API Gateway Service\n3. Click on your service in the left sidebar\n4. Click \"Binary Support\"\n5. Click the \"Edit\" button on the right side of the page\n5. Add `*/*` to the text input and click \"Save\"\n6. Click on your service in the left sidebar\n7. The \"Actions\" dropdown button should have an orange dot next to it, click on the \"Actions\" button.\n8. Click on \"Deploy API\" in the dropdown menu\n9. Select the \"dev\" service (or another service if you have configured one)\n10. Click the \"Deploy\" button\n\n## You're done!\n\nOnce you've reach this point your service is ready to use.\n\nYou can run `$ sls info` to print out the details about your service. You should see one \"endpoint\"\nthat has a `GET` method. Copy this URL and paste it into your browser. Replace `{proxy+}` with a\npath to one of your images in S3 (omitting the `BUCKET_NAME` defined in `serverless.yml`). For\nexample:\n\n```\nhttps://LAMBDA-ID.execute-api.eu-west-1.amazonaws.com/dev/path/to/image.png\n```\n\n# Usage\n\nServerless-Image-Resizer supports the following query params:\n\n| Parameter | Description | Format | Example |\n| --- | --- | --- | --- |\n| w | width   | number | `?w=150` |\n| h | height  | number | `?h=200` |\n| w\u0026h | crop | number | `?w=150\u0026h=200` |\n| f | filter  | string | `?q=Point` |\n| q | quality | number | `?q=2` |\n| m | max     | number | `?m=3` |\n| b | blur    | numberxnumber | `?b=0x7` |\n\nFor example:\n\n```\nhttps://LAMBDA-ID.execute-api.eu-west-1.amazonaws.com/dev/path/to/image.png?w=100\u0026h=200\u0026b=0x3\n```\n\n# Development\n\nAWS Lambda\n[supports node 6.10.2](http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)\nso that should be used during development. If you have [`nvm`](https://github.com/creationix/nvm)\ninstalled you can run `$ nvm use` to use the version in the `.nvmrc` file.\n\n## Linting\n\nThis project uses the [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb)\nlinting configuration. To run eslint execute the lint command:\n\n```sh\n$ npm run lint\n```\n\n## Testing\n\nTests are written and executed using [Jest](https://facebook.github.io/jest/). To write a test,\ncreate a `FILE_NAME.spec.js` file and Jest will automatically run it when you execute the test\ncommand:\n\n```sh\n$ npm test\n$ npm run test:watch     # to test as you develop\n$ npm run test:coverage  # to test code coverage\n```\n\nNote that `npm run test:coverage` will create a `coverage` folder that is gitignored.\n\n[david-dep-image]: https://david-dm.org/nicholasgubbins/serverless-image-resizer/status.svg\n[david-dep-url]: https://david-dm.org/nicholasgubbins/serverless-image-resizer\n[david-devDep-image]: https://david-dm.org/nicholasgubbins/serverless-image-resizer/dev-status.svg\n[david-devDep-url]: https://david-dm.org/nicholasgubbins/serverless-image-resizer?type=dev\n[npm-image]: https://badge.fury.io/js/serverless-image-resizer.svg\n[npm-url]: https://npmjs.org/package/serverless-image-resizer\n[travis-image]: https://travis-ci.org/nicholasgubbins/Serverless-Image-Resizer.svg?branch=master\n[travis-url]: https://travis-ci.org/nicholasgubbins/Serverless-Image-Resizer\n[twitter-image]: https://img.shields.io/twitter/url/https/github.com/nicholasgubbins/serverless-image-resizer.svg?style=social\n[twitter-url]: https://twitter.com/intent/tweet?text=Make%20your%20own%20serverless%20image%20processing%20API%20on%20AWS%20with%20this%20node%20package!%20https://github.com/nicholasgubbins/serverless-image-resizer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholasgubbins%2FServerless-Image-Resizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicholasgubbins%2FServerless-Image-Resizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholasgubbins%2FServerless-Image-Resizer/lists"}