diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3238e62 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000..bea40f0 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,10 @@ +FROM gitpod/workspace-full + +USER gitpod + +# Install custom tools, runtime, etc. using apt-get +# For example, the command below would install "bastet" - a command line tetris clone: +# +# RUN sudo apt-get -q update && # sudo apt-get install -yq bastet && # sudo rm -rf /var/lib/apt/lists/* +# +# More information: https://www.gitpod.io/docs/config-docker/ diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..daa8a83 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,4 @@ +tasks: + - init: pip install -r ./requirements.txt +image: + file: .gitpod.Dockerfile diff --git a/.idea/image-api.iml b/.idea/image-api.iml new file mode 100644 index 0000000..4e6ce24 --- /dev/null +++ b/.idea/image-api.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b6db721 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..dbc19f7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index a0ac0b6..e63ba4c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/gxercavins/image-api) + # Image API Image Processing API written in Python, using the Pillow library for image manipulation and exposing the functions with the Flask framework. The API has been tested with jpg, png and bmp formats and is able to flip, rotate and crop an image, as well as blending two images, either RGB or gray scale. diff --git a/app.py b/app.py index 3ab5de1..5a41619 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ from flask import Flask, request, render_template, send_from_directory import os from PIL import Image +import plat app = Flask(__name__) @@ -49,7 +50,7 @@ def upload(): @app.route("/rotate", methods=["POST"]) def rotate(): # retrieve parameters from html form - angle = request.form['angle'] + #angle = request.form['angle'] filename = request.form['image'] # open and process image @@ -57,7 +58,7 @@ def rotate(): destination = "/".join([target, filename]) img = Image.open(destination) - img = img.rotate(-1*int(angle)) + img = img.resize(plat.now) # save and return image destination = "/".join([target, 'temp.png']) @@ -71,7 +72,6 @@ def rotate(): # flip filename 'vertical' or 'horizontal' @app.route("/flip", methods=["POST"]) def flip(): - # retrieve parameters from html form if 'horizontal' in request.form['mode']: mode = 'horizontal' @@ -138,7 +138,7 @@ def crop(): # crop image and show if crop_possible: img = img.crop((x1, y1, x2, y2)) - + # save and return image destination = "/".join([target, 'temp.png']) if os.path.isfile(destination): @@ -178,9 +178,9 @@ def blend(): img2 = img2.convert('L') # blend and show image - img = Image.blend(img1, img2, float(alpha)/100) + img = Image.blend(img1, img2, float(alpha) / 100) - # save and return image + # save and return image destination = "/".join([target, 'temp.png']) if os.path.isfile(destination): os.remove(destination) @@ -197,4 +197,3 @@ def send_image(filename): if __name__ == "__main__": app.run() - diff --git a/core.py b/core.py index b933ef0..9eedcb5 100644 --- a/core.py +++ b/core.py @@ -14,7 +14,6 @@ def main(): return redirect("https://github.com/gxercavins/image-api/blob/master/README.md", code=302) - # rotate filename the specified degrees @app.route("/rotate//", methods=["GET"]) def rotate(angle, filename): diff --git a/plat.py b/plat.py new file mode 100644 index 0000000..a8322dc --- /dev/null +++ b/plat.py @@ -0,0 +1,2 @@ +sky = (1000, 1500) +now = (220, 340) \ No newline at end of file diff --git a/templates/processing.html b/templates/processing.html index 99d906e..80c1623 100644 --- a/templates/processing.html +++ b/templates/processing.html @@ -57,19 +57,19 @@

Crop

Rotate

-
- - + + +
- +

Blend

-
- + +
- +