Inconsistent behavior when sharing photos into pythonista?
paultopia last edited by
I've been doing some experiments with sharing image files into pythonista from the built-in photos app, to do things like zip up and share elsewhere. But I seem to get inconsistent data.
Here's my very simple experimental code:
import appex def test_save_images(): images = appex.get_images_data() for idx, image in enumerate(images): filename = "zfile-" + str(idx) + ".jpg" with open(filename, "wb") as ot: ot.write(image) if __name__ == '__main__': test_save_images()
Then I go into the built-in photos app, select two of photos, and share them into pythonista via "run pythonista script."
So far, I've done this twice, and neither time has it worked properly.
The first time, instead of saving both photos into the pythonista filesystem, it saved one photo, twice.
The second time, it saved both photos, but it saved a total of three photos---it saved one photo once, and one photo twice.
I obviously find this a little confusing. Why is
get_images_datanot passing the number of photos that I would expect into the script?