Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Pythonista Upload Photos from Library
-
@cvp the post above yours or which one ?
-
If you want to ftp upload the picked photos, I think you get the asset a binary data and to upload it without passing via a local copy.
Of course, if you want to show the photo without a local file, you can't use quicklook but an ImageView could be sufficient to show the image.... -
-
I don't have any FTP server accessible just now, but you can test this
#pil.save(os.path.join(os.path.dirname(sys.argv[0]), filename), quality=95) temp = io.BytesIO() pil.save(temp, format='JPEG', quality=95) temp.seek(0) #session.storbinary('STOR xxxxx.jpg' , temp)
The pil.save needs a format because, without file name, file type would be unknown
-
Please, if you try this one, please let me know if it is ok
import console import os, sys import photos import io import ui assets = photos.pick_asset(title='Pick some assets', multi=True) for asset in assets: pil = asset.get_image(original=False) iv = ui.ImageView() iv.image = asset.get_ui_image() iv.present('fullscreen') #pil.save(os.path.join(os.path.dirname(sys.argv[0]), filename), quality=95) temp = io.BytesIO() pil.save(temp, format='JPEG', quality=95) temp.seek(0) filename = '%s%s' % (console.input_alert('Rename File', 'Message: rename File', hide_cancel_button=False), '.PNG') #session.storbinary('STOR '+filename , temp)
-
@cvp said:
Please, if you try this one, please let me know if it is ok
import console import os, sys import photos import io import ui assets = photos.pick_asset(title='Pick some assets', multi=True) for asset in assets: pil = asset.get_image(original=False) iv = ui.ImageView() iv.image = asset.get_ui_image() iv.present('fullscreen') #pil.save(os.path.join(os.path.dirname(sys.argv[0]), filename), quality=95) temp = io.BytesIO() pil.save(temp, format='JPEG', quality=95) temp.seek(0) filename = '%s%s' % (console.input_alert('Rename File', 'Message: rename File', hide_cancel_button=False), '.PNG') #session.storbinary('STOR '+filename , temp)
this looks nice.
i try it. -
@cvp said:
Please, if you try this one, please let me know if it is ok
import console import os, sys import photos import io import ui assets = photos.pick_asset(title='Pick some assets', multi=True) for asset in assets: pil = asset.get_image(original=False) iv = ui.ImageView() iv.image = asset.get_ui_image() iv.present('fullscreen') #pil.save(os.path.join(os.path.dirname(sys.argv[0]), filename), quality=95) temp = io.BytesIO() pil.save(temp, format='JPEG', quality=95) temp.seek(0) filename = '%s%s' % (console.input_alert('Rename File', 'Message: rename File', hide_cancel_button=False), '.PNG') #session.storbinary('STOR '+filename , temp)
This works very well @cvp!
i do not need to remove any files ?goes this example also with the (german: Dateien App) Files App to select any file on my Documents ?
-
-
@DavinE said:
i do not need to remove any files ?
No because you did not create any file, you work in memory
-
@DavinE said:
goes this example also with the (german: Dateien App) Files App to select any file on my Documents ?
It should also be ok, but you would have to select a file and read it as binary file
-
-
-
@DavinE said:
this code snippet io.BytesIO()do that ?
Yes, it creates a bytes buffer accessible like a file object, with seek, read... what is needed by ftp.storbinary
-
-
-
@cvp said:
Yes, it creates a bytes buffer accessible like a file object, with seek, read... what is needed by ftp.storbinary
Thanks for your time to explain my that
-
@DavinE said:
the same way above ?
and how can i select them in Pythonista ?No no. Picked phoTos reads for you the photo file in memory (asset)
If you want to get all files of Files App, you will need to define an external open folder in the left browser of Pythonista.
-
Or you select a file in the Files App, not in Pythonista, and you share it to a Pythonista script which will receive the url of a temporary copy of the file, that you can upload to your ftp server.
But in this case, the selection is done in the Files App. -
@cvp said:
@DavinE said:
the same way above ?
and how can i select them in Pythonista ?No no. Picked phoTos reads for you the photo file in memory (asset)
If you want to get all files of Files App, you will need to define an external open folder in the left browser of Pythonista.
okay and then Pythonista have access to this folder and can Upload it ?
do you know the path of this external folders ? -
@DavinE said:
do you know the path of this external folders ?
It depends on which folder?
Example, I have a Numbers folder in iCloud Drive, for the standard app. Path is
/private/var/mobile/Library/Mobile Documents/com~apple~Numbers/Documents/Myfile.numbers