Trouble accessing exif information with PIL.Image._getexif()
<p>I am attempting to pull exif information from '.nef' files for the purposes of automatically sorting files into folders based on the retrieved data.</p>

<p>Based on my reading, it appears that PIL is a good choice for getting the information into Python.</p>

<p>I have PIL installed and it imports correctly, as does the PIL.Image module.</p>

<p>The problem arises when I attempt to call 'PIL.Image._getexif()'</p>

<pre><code>from PIL import Image
from PIL.ExifTags import TAGS

firstfile = 'link to file'
exif = Image._getexif(firstfile)
</code></pre>

<p>That gets this error:</p>

<pre><code>AttributeError: 'module' object has no attribute '_getexif'
</code></pre>

<p>A longer version of the code also gets an error:</p>

<pre><code>def get_exif(fn):
    ret = {}
    i = Image.open(fn)
    info = i._getexif()
    for tag, value in info.items():
        decoded = TAGS.get(tag, tag)
        ret[decoded] = value
    Image.close(fn)
    return ret

exifinfo = get_exif(firstfile)
</code></pre>

<p>This fails with:</p>

<pre><code>AttributeError: _getexif
</code></pre>

<p>Perhaps I have PIL installed wrong?  Why is '_getexif()' not able to be called?</p>

<p>Notes:
The only google results for a direct search of "AttributeError: 'module' object has no attribute '_getexif'" are old/404'd not helpful, leading me to believe this is not a common problem to have.</p>