-
|
Hi, first of all, I am very impressed by Pythonista and the tons of possibilities it offers for me on my iOS devices and I am as well impressed from the community around. I am really looking forward for the next release. As an amateur photographer I liked the possibilities an iPad has to offer. It is easy to integrate external cameras and is a lightweight solution on travel. Apple shortcuts, Pythonista, iSH and a-shell are a magic bag for automation. Travelling within different timezones and sometimes forgot to collect GPS data for my external camera, I experienced "inconsistencies" in the metadata of the images in my iOS Photolibrary. I believe I have researched nearly all sources I found to extract metadata. Best method so far I found is described in this article: def exif(self):
"""Return EXIF data of the Asset if existant"""
info = self.fetch_data()
img_data = info['data']
if self._exif is not None:
return self._exif
# Extract EXIF data from Asset via CIImage
cImage = None
CIImage = ObjCClass('CIImage')
cImage = CIImage.imageWithData_(img_data) if img_data else None
if not cImage:
return None
props = None
props = cImage.properties()
if props is None:
result = None
else:
self._exif = parse_ns_dictionary_string(str(props['{Exif}']))
props = None # Release object
cImage = None # Release object
if cImage: del cImage # Release object
if props: del props
if hasattr(self, '_exif'):
return self._exif
return NoneI call the exif method for every asset in the Photolibrary for a day of my trip and can repeat it for more days. But may be someone here in the community has an idea how to overcome the memory increase. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 26 replies
-
|
I'm not sure if this will help you, but I recommend using Rubicon-ObjC instead of There are several ways to use Rubicon-ObjC in Pythonista:
|
Beta Was this translation helpful? Give feedback.
-
|
I wonder if the autorelease method might be the key to this? I’m no expert on Objective C integration, but this code has helped me several times to highlight the locations of memory leaks Hope either of these might help |
Beta Was this translation helpful? Give feedback.
-
|
Hello, almost sure this post would not help you, but in the past I have written a lot of code in Pythonista for my photos, and to get their exifs, I always had used |
Beta Was this translation helpful? Give feedback.
HI @mmccthomas I am pretty sure I have tried this too and found the EXIF metadata for HEIC is quite minimalistic. But only if you take the image data form asset.get_image_data. If you open a HEIC file it is much better.
By now I have tried the solution suggested by ChatGPT, with some code generated.
From the tests I have made so far I can say the memory consumption (not the value I get from 'resource.getrusage') is flat. I could go in the loop far beyond I ever was.
I have updated my gist with the updated code (https://gist.github.com/shield61/93deb01c979d2ffe83f75cf5efc2b1fc).
I will try afterwords the ExifRead method again. May be my memory was not correct and the continue with using ru…