jrh147
Nov 13, 2015 - 03:12
I need to encode images in base64 for the purposes of passing them through an x-callback-url. I have this code but it's not working:
#coding: utf-8
import workflow
import clipboard
import photos
import base64
source_selection = workflow.get_variable('source')
if source_selection == 'photo':
image_selection = photos.pick_image()
else:
image_selection = clipboard.get_image()
if not image_selection:
console.alert('No Image', 'Clipboard does not contain an image')
w, h = image_selection.size
encoded = base64.b64encode(str(image_selection)
workflow.set_variable('encodedImage', str(encoded))
workflow.set_variable('origSize', str(w))
Any ideas?