kevinptx / udacity-image-processing-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image Processing API

This is a Node.js-based image processing API that provides functionality for resizing images and logging HTTP requests and responses. It is a simple Image Processing API built with Node.js, Express, and the Sharp image processing library. It provides endpoints to resize images and log HTTP requests and responses. It is the first project for Udacity's Full Stack JavaScript Developer Nanodegree.

Table of Contents

Features

  • Resize images to specified dimensions using the Sharp library.
  • Log incoming HTTP requests and responses with timestamps.

Getting Started

Requirements

  • Node.js (v12 or higher)
  • npm package manager
  • Git (for cloning the repository)

Installation

  1. Clone the repository:
    git clone https://github.com/kevinptx/udacity-image-processing-api
    cd image-processing-api
    npm install
  2. Install the required Node.js packages using npm:
    npm install
  3. Build the TypeScript files:
    npm run build
  4. Run the tests to ensure everything is set up correctly:
    npm test
  5. Start the server:
    npm start
  6. Open your web browser and navigate to http://localhost:3000 to access the Image Processing API.

Functionality

To resize an image, send a GET request to /resize with the following query parameters:

  • filename: The name of the image file you want to resize (including the file extension).
  • width: The desired width of the resized image.
  • height: The desired height of the resized image.

The Image Processing API allows you to resize images by sending a GET request to the following endpoint:

http://localhost:3000/resize?filename=<image-filename>&width=<desired-width>&height=<desired-height>

Example: http://localhost:3000/resize?filename=fjord.jpg&width=200&height=200

The resized image will be saved to disk on first access and then pulled from disk on subsequent access attempts. If the image processing fails or the image does not exist, an appropriate error message will be returned.

To view the logs of HTTP requests and responses, check the terminal where the server is running.

Endpoints

GET /resize

Query Parameters:

  • filename (string, required): The name of the image file you want to resize (including the file extension).
  • width (number, required): The desired width of the resized image.
  • height (number, required): The desired height of the resized image.

Example: /resize?filename=fjord.jpg&width=200&height=200

Tests

Run the tests using the following command:

npm test

License

This project is licensed under the MIT License

About


Languages

Language:TypeScript 88.2%Language:HTML 11.8%