Forum Archive

Using photos module

lillumultipass141

Hi to all!

I am new to pythonista and to Python as well. Looking at the latest pythonista version, I saw that there is a photo module. Hence, I was thinking about writing a small script to speed up my workflow: the idea would be to take a screenshot or photo (manually) and then launch a script that would:
- select the last photo in the camera roll (the screenshot)
- attach it to en email allowing me to choose the email address each time (I already know this is doable)
- delete the picture/screenshot from the camera roll.

Would it be possible?
Thanks!

omz

Certainly possible, except for one thing: You can't delete images from the camera roll. It's just not possible to do this for App Store apps, this is not a Pythonista-specific limitation.

Getting the last image from the camera roll is very simple:

import photos
img = photos.get_image()

For an example of how to send an email with an image attachment, using smtplib, have a look at this script:
https://gist.github.com/omz/4073599

For entering the email address, you could either use the input_alert() function in the console module, or just use Python's built-in raw_input() function.

lillumultipass141

Thanks for such a quick answer!
That's what I was afraid though...I will have to think about a workaround because I tend to take a lot of screenshots of things I don't want to keep but I just want to send into Evernote for instance, and I'd rather automate the delete part...

lillumultipass141

Oh, and another question: would it be possible to write a program that would allow to rectangle-select a part of the screen and then copy it to the clipboard?
It would also have to allow to open different apps or the latest app open before the script was launched...