Skip to content

Instantly share code, notes, and snippets.

@alexruimy
Created December 26, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexruimy/0bad1f51f2be0c8aca0f193d18b2deab to your computer and use it in GitHub Desktop.
Save alexruimy/0bad1f51f2be0c8aca0f193d18b2deab to your computer and use it in GitHub Desktop.
DAE Sample
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