Skip to content

reading android image return: AttributeError: 'NoneType' object has no attribute 'size' #23

@pat1

Description

@pat1

with this simple test program:

import pexif

# Modify  the exif in a file
img = pexif.JpegFile.fromFile("test.jpg")
img.exif.primary.ImageDescription =  "Hello world!"
img.writeFile("tmp1.jpg")
python test.py 
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    img = pexif.JpegFile.fromFile("test.jpg")
  File "/home/pat1/tmp/jpg/pexif.py", line 1002, in fromFile
    return JpegFile(f, filename=filename, mode=mode)
  File "/home/pat1/tmp/jpg/pexif.py", line 1065, in __init__
    attempt = segment_class(mark, input, data, self.mode)
  File "/home/pat1/tmp/jpg/pexif.py", line 858, in __init__
    DefaultSegment.__init__(self, marker, fd, data, mode)
  File "/home/pat1/tmp/jpg/pexif.py", line 151, in __init__
    self.parse_data(data)
  File "/home/pat1/tmp/jpg/pexif.py", line 902, in parse_data
    ifd = IfdTIFF(self.e, offset, self, self.mode, tiff_data)
  File "/home/pat1/tmp/jpg/pexif.py", line 418, in __init__
    actual_data = self.embedded_tags[tag][1](e, the_data, exif_file, self.mode, data)
  File "/home/pat1/tmp/jpg/pexif.py", line 412, in __init__
    exif_type_size(exif_type), components,
  File "/home/pat1/tmp/jpg/pexif.py", line 250, in exif_type_size
    return ExifType.lookup.get(exif_type).size
AttributeError: 'NoneType' object has no attribute 'size'

attached the sample image; sorry for the subject ;)

test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions