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 debug crash of image script when it's called as extension
-
@cvp Thanks for the detailed script.
One thing I am wondering about is: You get the images from the share extension as PIL images via
appex.get_attachments()
and then convert them to UI images. Isn't there a way to get them directly as UI images? I thought UI image is the iOS-native format...
-
@halloleooo you're right but we got some problems with images in appex mode, thus...
Else, I use this where you can set type you wantimg = appex.get_image(image_type='pil')
-
Doesn't appex provide a
get_ui_image
function? That will be much lighter weight than going through PIL and back. -
@JonB sure, he knows that, but in the past, we got some problems with it.
Édit: believe me, if we go through pil, it is not for the pleasure to do it.
-
@cvp So what are the problems with
get_ui_image
? -
Correction: appex does not have a get_ui_image
-
We mixed with asset.get_ui_image
-
I have been disturbed only because the post comes from @JonB
-
@halloleooo doc dixit, you could try with
img = appex.get_image(image_type='ui')
#files = appex.get_attachments() #for f in files: files = appex.get_images(image_type='ui') for ui_image in files: #pil = Image.open(f)#,mode='r') #ui_image = pil2ui(pil) #del pil
-
I think the Pyhonista docs mentions
appex.get_ui_image()
. Is this wrong? -
@halloleooo modif just above also crashes with two big photos...
-
@halloleooo said:
I think the Pyhonista doco mentions appex.get_ui_image(). Is this wrong?
The internal doc, reached via help, and the source of appex.py do not mention it
-
@halloleooo but, as I said previously, asset.get_ui_image exists
-
@halloleooo print dir(appex) to confirm
-
@halloleooo I said"modif just above also crashes with two big photos..." but with pil it works
-
@halloleooo ok, now, Forget all, this works, by commenting the del ui_image
and is quicker than converting pil
even with wi=1000 with two photos of 2600x4000 pixels# assume two images are shared #files = appex.get_attachments() #for f in files: files = appex.get_images(image_type='ui') for ui_image in files: #pil = Image.open(f)#,mode='r') #ui_image = pil2ui(pil) #del pil w,h = ui_image.size wi = 400 hi = wi*h/w with ui.ImageContext(wi,hi) as ctx: ui_image.draw(0,0,wi,hi) #del ui_image ui_resize = ctx.get_image() ui_images.append(ui_resize) del ui_resize
-