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.
How to share JPEGs via dialogs.share_image?
-
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 afile_path
. -
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 wordsAnyway, I only wanted to say that they are similar because in solid state material both
-
-
@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