Forum Archive

Access image file from ios share sheet to get file size (and possibly change it)

ChrisHare

So - I am new to Pythonista and running python on iOS, so this may have been solved by someone already.

What I want to do is be able to select one or more image files from the Files.app, and run my Pythonista script from the share sheet. The Pythonista app will get the image dimensions (width x height) and print the results.

Ideally, being able to provide the desired dimensions as either both width and height, or if only value is provided, adjust the other by the same percentage.

What is the best approach to this?

Thanks

cvp

@ChrisHare this script does exactly what you want

import appex
ui_image = appex.get_image(image_type='ui')
print(ui_image.size)

In Photos, you
- select one
- tap share button
- tap "run Pythonista script"
- tap "edit scripts"
- choose this script
- tap the run button

Of course, if you want to use frequently, you can add it to the Pythonista share scripts