Try to get pictures from Ipad from specific album
Ill try to get images from a album on my ipad to use for a background and a button image.
Get a picture with:
all_assets = photos.get_assets()
last_asset = all_assets[-1]
img = last_asset.get_image()
But how do i get the img out a specific albums?
With photos.get_albums() i get <AssetCollection "App_Python kopie" - 00000000-0000-0000-0000-000000000063/L0/040 (album)>
In the "App_Python kopie" album are mij images. I hope something AssetCollection.asset would do the trick, but im just started with python and don,t now how to do it.
So i hope somebody can help me and explain how the logic is behind the code.
dgelessus last edited by dgelessus
photos.get_albums()gives you a list of all albums. To get an album for a specific name, you can do something like this:
# Go through all albums... for album in photos.get_albums(): # ...find the one with the correct name... if album.title == "App_Python kopie": # ...and put it in a variable, then stop the loop. my_album = album break
And you can get the list of assets in an album from the
last_asset = my_album.assets[-1] last_asset.get_image().show()
But if you want to use an image for a button icon, it's easier to import it into Pythonista. In the file list, tap the "+" button, then select "Import Photo...". Then you can load it by file name, like:
# For ui (buttons, etc.) import ui img = ui.Image("IMG_1234.JPG") img.show() # For PIL (image editing and processing) import PIL.Image img = PIL.Image.open("IMG_1234.JPG") img.show()
Thanks, it look very easy, but now i understand im still a newbie.
I,ll try to use the "Import Photo..." methode, but it look like my ipad can only see my "filmroll" instead of the images in the ipad "foto's app".
Im sharing the "camera" and "foto's app" with phythonista, does other pl. have the same problem?
I just fiddel with the the phythonista settings and now the script of photos is not running any more ;(
RMurtsoo last edited by omz
With this scrypt:
import photos for album in photos.get_albums(): if album.title == "App_Python kopie": my_album = album break last_asset = my_album.assets[-1] last_asset.get_image().show()
I get now this error: NameError: name 'photos' is not defined
the first time it just worked, im not sure wat i changed, the setting for phytonista is sharing "camera" and "foto,s app" Olso the settings in the Privacy section in the Settings app are "green"
The album "App_Python kopie" still there.
Them this is mind break_ing
I hope to hear something.
The script is working again i had to re_install pythonista, can i get now a refund ;) because i found a bug.
No i love the app still.
im not sure how i got the bug, but i think it had something to do with try to share a image in "foto's app" with Pythonista.
Back to scripting: