I use dialogs.share_image(img) to share an photo from Pythonista to other apps.
The photo is given as a PiL image and it seems to be shared as a PNG which is pretty inefficient for photos.
Any idea how I can share the photo as a JPEG?
I use dialogs.share_image(img) to share an photo from Pythonista to other apps.
The photo is given as a PiL image and it seems to be shared as a PNG which is pretty inefficient for photos.
Any idea how I can share the photo as a JPEG?
@halloleooo this shares a jpg
import console
console.open_in('a.jpg')
Thanks @cvp.
Does this mean I have save the PIL image first as a JPG to disk and then I can share it?
https://omz-software.com/pythonista/docs/ios/console.html says that console.open_in() takes a file_path.
@halloleooo
import console
from PIL import Image
import os
pil = Image.open('test:Lenna')
pil.save('test.jpg', quality=95)
console.open_in('test.jpg')
os.remove('test.jpg')
@halloleooo said:
Does this mean I have save the PIL image first as a JPG to disk and then I can share it
Yes sir
Thanks for the details. I was hoping to be able to tweak dialogs.share)image to export JPGs, but the detour via a JPG file is ok too.
Thanks again!
@halloleooo said:
hoping to be able to tweak dialogs.share)image to export JPGs
I don't think it is possible but I can be wrong
@cvp said:
save the PIL image first as a JPG to disk
Don't forget that on a iDevice, files are also in RAM 🤔
I woulda said that solid state disk (SDD/flash) != RAM but perhaps someone could correct me.
@ccc solid state memory = transistors
RAM = read and write memory = transistors too
Agree this not the same, specially in access speed, buT not exactly a disk which is in movement...
Only different words
Anyway, I only wanted to say that they are similar because in solid state material both
@cvp @ccc Funny, funny., but a good point: These days everything is semiconductors...
In regards to the problem at hand: Using the file systems means I have to create a tmpdir first I guess - or where the heck does the stuff get saved when Pythonista executes in a share extension???
@halloleooo said:
where the heck does the stuff get saved when Pythonista executes in a share extension???
I guess in the same folder as the script.
And no need of temp dir if you remove it just after sharing.
As usual, Python has nice batteries included...
https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile