A flask based web api to merge a two PNG images(i.e background and foreground) and return the merged image url and in base64 format
CSS Python JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
static
templates
.gitignore
LICENSE
Procfile
README.md
app.py
merger.py
requirements.txt
settings.py

README.md

#Image-Merger-API V1.0

A Flask based Web API to merge a two PNG images(i.e may be background and foreground) and it returns the output image url and in base64 format also. The API is REST API and uses nothing for user authentication purposes. Currently, return format for all endpoints is JSON.


##API Resources and URI Structure URIs for a Image Merging REST API resource have the following structure:

http://image-merger.herokuapp.com/api/v1.0/

Method Supported : POST

Send a payload of JSON format like this:

{
   "foreground_url" : "image url",
   "background_url" : "image url"
}

Note :

  1. Request must be JSON type i.e Content-Type : application/json
  2. Images should be of same sizes and of PNG format.

##Media Types This REST API return HTTP responses in JSON formats:

{
    "output_image" : {
        "name" : "Image Name",
        "url" : "Image Absolute Url",
        "base64" : "Image in base64 format"
    }
}

You can download the merged output image through url returned in reponse.

##HTTP Error Response This REST API also return HTTP error response in JSON formats with proper HTTP Status Code as follows:

{
   "Error" : "Message"
}

Error Message may be of following types:

  • Not Valid Url ( HTTP Status Code : 202 )
  • Images Not Found ( HTTP Status Code : 202 )
  • Format Not Supported ( HTTP Status Code : 202 )
  • Not Same Size Images ( HTTP Status Code : 202 )
  • Internal Error. Please Try Again ( HTTP Status Code : 202 )
  • Bad Request ( HTTP Status Code : 400 )
  • Not Found ( HTTP Status Code : 404 )
  • Method Not Allowed ( HTTP Status Code : 405 )
  • Internal Server Error ( HTTP Status Code : 500 )

##Example Let we make a POST request with payload in valid format, like this:

{
   "foreground_url" : "http://akshayon.net/images/foreground.png",
   "background_url" : "http://akshayon.net/images/background.png"
}

Foreground Image Foreground Image

Background Image Background Image

Then , we get a response in JSON style , like this:

{
    "output_image" : {
        "name" : "5c359e06d7b9e4c21b699758c18ce335.jpeg",
        "url" : "http://image-merger.herokuapp.com/image/5c359e06d7b9e4c21b699758c18ce335.jpeg",
        "base64" : "iVBORw0KGgoAAAANSUhEUgA.....SUVORK5CYII="
    }
}

Merged Output Image Merged Image