The Image Processor allows you to resize an image of any size to view in your browser, or to download a library of resized thumbnails.
This application was written in Node, Express, Sharp, and Typescript, and tested with Jasmine and Supertest by @newwebash.
To view resized image in the browser:
-
Start the application on a local server using the script below.
-
Place the image you'd like to resize in the
application/pre_processeddirectory. Or, feel free to use one of the image files already found in the directory. -
Open the browser of your choice and go to
http://localhost:3000/api/resizeImage?filename=<YOUR_IMAGE.EXT>&width=<YOUR_WIDTH>&height=</YOUR_WIDTH>For example, if you want to resize the
santamonica.jpgfile to 300 pixels wide and high, visithttp://localhost:3000/api/resizeImage?filename=santamonica.jpg&width=300&height=300Result: The resized image shows in your browser. Feel free to re-use this url to embed the image in your website.
To get the thumbnail library:
- Go to the
application/processeddirectory. This contains all images that have been generated so far. Feel free to download the entire directory or individual files as needed. - If you don't see the thumbnail size you want, you can generate it following the instructions above. Alternatively, you can query the endpoint via Postman or Curl.
This applicaton has been tested with Jasmine and Supertest. You can run the tests and see test output by running the build and test script listed below.
Install project dependencies
npm i
Run linter
npm run lint
Run code formatter
npm run prettier
Build project
npm run build
Build project and run tests (Jasmine and Supertest)
npm run test
Start the local server
npm run start
To help inform how to code this project, I gathered information from the following resources:
- Udacity course content
- Documentation for node modules used
- How To Process Images in Node.js With Sharp article from Digital Ocean.