Created
December 26, 2018 19:35
-
-
Save alexruimy/0bad1f51f2be0c8aca0f193d18b2deab to your computer and use it in GitHub Desktop.
DAE Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import requests | |
from PIL import Image | |
API_KEY = 'xxxxxxxx' | |
UPLOAD_URL = 'https://api.deeparteffects.com/v1/noauth/upload' | |
STYLES_URL = 'https://api.deeparteffects.com/v1/noauth/styles' | |
RESULT_URL = 'https://api.deeparteffects.com/v1/noauth/result?submissionId=%s' | |
HEADERS = {'x-api-key': API_KEY} | |
def encode_image(image_file): | |
with open(image_file, "rb") as image_file: | |
encoded_string = base64.b64encode(image_file.read()) | |
return encoded_string | |
def upload_image(image_file, style_id, original_colors=True): | |
data = { | |
"styleId": style_id, | |
"imageBase64Encoded": encode_image(image_file), | |
"optimizeForPrint": True, | |
"useOriginalColors": original_colors, | |
} | |
r = requests.Request('POST', UPLOAD_URL, data=data, headers=HEADERS) | |
prepared = r.prepare() | |
r = requests.post(UPLOAD_URL, data=data, headers=HEADERS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment