Passing An Image Back To Workflow
If I correctly understood your request, you don't need Workflow because your Pythonista script could perform it-self all your "actions", like
- select photos
- convert them
- save them to an album
abcabc last edited by
My example is for illustration purpose only and I do not require that workflow. My sentiments are similar to the ones expressed in the following blog.
But the template could be useful in doing something very fast with little code, may be at some time later. Your comments are very helpful in building the template.I have also looked at the workflow site
https://workflow.is/developer and the reddit site https://www.reddit.com/r/workflow
I do not want to investigate much into this now and I am ok with current action script template.
Once again I would like to thank you for your helpful comments and I will look at your"x-callback-url" some time later.
Before I know Pythonista, I wrote a lot of Workflows, but since I use Pythonista, I've rewritten all in Python, with only one exception for Workflows saving or getting a file to/from ICloud Drive because Pythonista does not provide this functionality.
ccc last edited by ccc
Would it be possible to interop with iCloud Drive using objc_utils? Or with something like https://pypi.python.org/pypi/pyicloud
I don't think so, I had already seen this import but it does not cover the iCloud Drive storage, only ICloud services.
To reveal a little more of the picture...
... My idea was to create a graphing Pythonista capability so Workflow might pass a CSV (file) into Pythonista and then do something with the graph (image) returned.
In essence I wanted to add graphing to Workflow. I would expect Pythonista would be a good way to do it.
Would Editorial do this better than Pythonista?
ccc last edited by
Phuket2 last edited by
@MartinPacker , I am not really sure about Editorial vrs Pythonista for the graphing, they could be equivalent. But my guess would be that Pythonista would be the superset of functionality.
But just really wanted to mention the 'Pie Chart Demo.py' in the Examples/Plotting dir in Pythonista. Great demo how to easily create a pie chart with some nice features. It's so easy to understand. Then I am pretty sure if you use a ui.ImageContext to draw into you could return that image for the clipboard. Possibly the matplotlib gives a more direct way. Just interesting
cvp last edited by cvp
I had checked this page but they only support iCloud file storage, that will say Apple apps storage, like Notes, but not iCloud Drive storage of all other apps, what does Workflow app.
In Workflow, you can save a file to the ICloud Drive of another app, like Documents, FileBrowser, Pages, Numbers etc...
It's exactly like you can manually do in Pythonista by
- select a file
- add to ICloud Drive
All this talk about iCloud illustrates one of the reasons why I'm not looking for a "write to file" solution.
Clipboard would be fine, though "trashing" the clipboard should only be done if necessary. It seems that it is.
Something for y'all to pick the bits out of...
A reply from @WorkflowHQ on Twitter contained the following...
"Also regarding sending images, Workflow can decode base64 encoded images."
Does this help us here? Can we encode images base64?
omz last edited by
@MartinPacker Encoding images as base64 should be fairly straightforward in Python. Do you have any more details?
ccc last edited by
omz last edited by
I figured out how to do it without using the clipboard. The trick is basically to use "Get Contents of URL" with a
data:URI that gets passed to the workflow via the
workflow://scheme, containing base64-encoded image data.
Here's the script:
import webbrowser import base64 from PIL import Image import io from urllib.parse import quote img = Image.open('test:Lenna') buffer = io.BytesIO() img.save(buffer, 'PNG') data_uri = 'data:image/png;base64,' + base64.b64encode(buffer.getvalue()).decode('ascii') webbrowser.open('workflow://run-workflow?name=EditBase64Image&input=' + quote(data_uri, ''))
...and the workflow should be something like this:
shtek last edited by
invalid base64 encode.
remove 'data:image/png;base64,' like this:
data_uri = base64.b64encode(buffer.getvalue()).decode('ascii')
now it works