Skip to content

A nestjs based backend which is build to optimise(compress) the image quality by 50%

Notifications You must be signed in to change notification settings

imrosun/image-processing-system

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

API Documentation / Postman Collection APIs

I have used "render" for hosting and when it is inactive then it can delay requests by 50 seconds or more. Kindly have patience till one request after that it becomes fast

Copy curl and paste on postman to test APIs

curl --location 'https://image-processing-system-vmeb.onrender.com/process-image/upload' \
--form 'file=@"/path/to/file"'
  • Body: give Key as file and Attach csv file on Value

  • On success you will recieve requestId which will be in the form of shown below. It will help to check processing status. You can check the status of Image whether it is compressed or still in pending status.

  • Response: { "message": "File uploaded successfully", "requestId": "80a03f07-e6e0-4a23-b356-c1d16c6a0434" }

  • GET https://image-processing-system-vmeb.onrender.com/process-image/status/:requestId

    • Using the above endpoint you will be able to check processing status and see the compressed images in imageOutputUrls form
curl --location 'https://image-processing-system-vmeb.onrender.com/process-image/status/80a03f07-e6e0-4a23-b356-c1d16c6a0434' \
--data ''
curl --location 'https://image-processing-system-vmeb.onrender.com/process-image/webhook' \
--header 'Content-Type: application/json' \
--data '{ 
    "requestId": "80a03f07-e6e0-4a23-b356-c1d16c6a0434"
}'
curl --location 'https://image-processing-system-vmeb.onrender.com/process-image/' \
--header 'Content-Type: application/json'
  • Response: [{List out the uploads}]
  • This can be disabled if needed

Description

The project appears to be a Node.js application using NestJS that processes and compresses images and integrates with MongoDB and AWS S3.

Key Features:

  • Image Processing:
  • Fetch Images: Retrieves images from given URLs.
  • Compress Images: Utilizes sharp for image compression and resizing. Implements a quality adjustment and resizing to reduce image size effectively.
  • Image Upload: Compresses images further using imagemin and mozjpeg, and uploads the processed images to AWS S3.

Database Integration:

  • MongoDB: Stores image processing records and metadata using Mongoose. Connects to MongoDB using a URI from environment variables.

Configuration Management:

  • Uses @nestjs/config to handle configuration and environment variables.

Error Handling:

  • Handles errors during image processing and uploading, including network errors and invalid URLs.

Webhook Notifications:

  • Sends notifications via webhook upon processing completion, including information about failed URLs.

Data Management:

  • CSV Processing: Parses and processes CSV files containing image URLs and other metadata.
  • Database Operations: Provides CRUD operations for managing image processing records.

Technologies Used:

  • NestJS: Framework for building the application.
  • Sharp: For image manipulation and compression.
  • AWS S3: For storing processed images.
  • Mongoose: For MongoDB interaction.
  • ConfigModule: For configuration management.

Application Flow:

  • CSV Upload: Users upload CSV files containing image URLs.
  • Image Processing: Images are fetched from URLs, resized, and compressed.
  • Storage: Processed images are uploaded to AWS S3.
  • Record Update: Database records are updated with the status and URLs of processed images.
  • Notification: A webhook is triggered to notify completion and report any failed URLs.

Nest framework TypeScript starter repository.

Installation

# clone the repository
$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

License

Nest is MIT licensed.

About

A nestjs based backend which is build to optimise(compress) the image quality by 50%

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published