An adaption of tinify as a flask extension
Install the API client:
pip install flask-tinify
from flask import Flask
from flask_tinify import Tinify
app = Flask(__name__)
tinify = Tinify(app)
from flask import Flask, request
from flask_tinify import Tinify
app = Flask(__name__)
tinify = Tinify(app)
@app.route('/tinify', methods=['POST'])
def hello_png():
image = request.form['image']
if not image:
return '', 400
with image.strem as stream:
tinify.from_buffer(stream.read()).to_buffer()