Giter VIP home page Giter VIP logo

image-manipulation-api-digitalocean's Introduction

image-manipulation-api-digitalocean

Star on GitHub Fork on GitHub Watch on GitHub

Version 0.0.2 License: MIT Built with Python

image-manipulation-api-digitalocean is a Flask-based web service designed to perform various image processing tasks. It provides endpoints for resizing, cropping, rotating, converting to grayscale, adjusting brightness and contrast, flipping, applying filters, converting formats, adding text, and listing available fonts. This API deploys to DigitalOcean within a Docker container.

Dependencies

  • Python: The script runs in a Python3 environment.
  • Flask: This is used for creating the web server and handling the REST API HTTP requests.
  • Flask-CORS: Handles Cross-Origin Resource Sharing (CORS).
  • gunicorn: An extension that provides a Python WSGI HTTP Server for UNIX.
  • NumPy: Used for handling numerical data, particularly arrays.
  • OpenCV: Utilized for image processing tasks like reading, resizing, cropping, rotating, converting color spaces, applying filters, and encoding images.

Deploy to DigitalOcean App Platform

Click this button to deploy the project to your Digital Ocean account:

Deploy to DO

Installation

To install image-manipulation-api-digitalocean, follow these steps:

Begin by cloning the repository containing the image-manipulation-api-digitalocean to your local machine.

git clone https://github.com/samestrin/image-manipulation-api-digitalocean/

Navigate to the project directory:

cd image-manipulation-api-digitalocean

Install the required dependencies using pip:

pip install -r src/requirements.txt

Endpoints

Resize Image

Endpoint: /api/resize Method: POST

Resize an image to the specified width and height.

Parameters

  • image: Image file
  • width: Target width (integer)
  • height: Target height (integer)

Crop Image

Endpoint: /api/crop Method: POST

Crop an image to the specified coordinates.

Parameters

  • image: Image file
  • x1: Starting x-coordinate of the crop area (integer)
  • y1: Starting y-coordinate of the crop area (integer)
  • x2: Ending x-coordinate of the crop area (integer)
  • y2: Ending y-coordinate of the crop area (integer)

Rotate Image

Endpoint: /api/rotate Method: POST

Rotate an image by the specified angle.

Parameters

  • image: Image file
  • angle: Rotation angle in degrees (float)

Convert to Grayscale

Endpoint: /api/grayscale Method: POST

Convert an image to grayscale.

Parameters

  • image: Image file

Adjust Brightness

Endpoint: /api/brightness Method: POST

Adjust the brightness of an image.

Parameters

  • image: Image file
  • factor: Brightness adjustment factor (float)

Adjust Contrast

Endpoint: /api/contrast Method: POST

Adjust the contrast of an image.

Parameters

  • image: Image file
  • factor: Contrast adjustment factor (float)

Flip Image

Endpoint: /api/flip Method: POST

Flip an image horizontally or vertically.

Parameters

  • image: Image file
  • axis: Flip axis (horizontal or vertical)

Apply Filter

Endpoint: /api/filter Method: POST

Apply a filter to an image.

Parameters

  • image: Image file
  • filter_type: Filter type (blur, sharpen, or edge_detect)

Convert Image Format

Endpoint: /api/convert Method: POST

Convert the format of an image.

Parameters

  • image: Image file
  • output_format: Output format (e.g., png, jpeg)

List Fonts

Endpoint: /api/list_fonts Method: GET

List available fonts for adding text to images.

Add Text to Image

Endpoint: /api/add_text Method: POST

Add text to an image.

Parameters

  • image: Image file
  • text: Text to add
  • font: Font type (integer)
  • font_size: Font size (integer)
  • left: Left position of the text (integer)
  • top: Top position of the text (integer)
  • color: Text color in RGB format (optional)

Error Handling

The API handles errors gracefully and returns appropriate error responses.

  • 400 Bad Request: Invalid request parameters.
  • 500 Internal Server Error: Unexpected server error.

Frontend/Testing Interface

The image-manipulation-api-demo project is a simple testing interface that utilizes Bootstrap and jQuery for AJAX-based interactions with the image-manipulation-api-digitalocean.

Contribute

Contributions to this project are welcome. Please fork the repository and submit a pull request with your changes or improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Share

Twitter Facebook LinkedIn

image-manipulation-api-digitalocean's People

Contributors

samestrin avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.