Git Product home page Git Product logo

exif-py's People

Contributors

a143416 avatar abnsy avatar angel6700 avatar chrstphrchvz avatar echsecutor avatar etiennepelletier avatar grucin avatar ianare avatar jbeda avatar jcea avatar michaelmonashev avatar nickdimitroff avatar nirzak avatar ortsed avatar paulbarton90 avatar paulinus avatar peteblois avatar peterreimer avatar pgrimaud avatar pierotofy avatar rom1504 avatar rshk avatar rudisimo avatar samrushing avatar sim1camporeale avatar tassoneroberto avatar tonykwok avatar tzdyrski avatar ungeheurenungeziefer avatar velis74 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exif-py's Issues

Please re-enable Travis

Hi @ianare

Please can you re-enable Travis for this repository?

Also is the repo still actively maintained, if not please can we discuss maybe someone else taking over maintenance of the repo moving forward as it is a Python module we love using.

Best Regards,

Rob

python3.2.3 support

Hi,
First thanks for the excellent work.
I'm trying to use this with Python 3.2.3 and have run across some issues.

  1. In order to get the if to work for detecting the file type I had to change if data[base:base+2]=='\xFF\xE1': to if data[base:base+2]==b'\xFF\xE1':
    Adding a b binary flag (this also was fine when running with python2.7
  2. Issue with ord() i.e.
    File "EXIF.py", line 1691, in process_file
    base=base+ord(data[base+2])*256+ord(data[base+3])+2
    TypeError: ord() expected string of length 1, but int found
    I think if the ord() calls are removed (no convert needed) this fixes it for python3.2.3 (but will have issues on 2.7).
  3. It then fails at the following (data[base:base+2] is empty):
    Segment base 0xCAD0
    Unexpected/unhandled segment type or file content.

It would be excellent to have this working for Python 3.2.3 if possible. Works excellently with 2.7.
Many thanks.

Choking on GPS IFD

I'm using 1.4.2 but it also happens in 2.0 .

Here's the image that causes the problem.

DEBUG JPEG format recognized data[0:2]=0xFFD8
DEBUG data[2]=0xFF data[3]=0xE1 data[6:10]=Exif
DEBUG Segment base 0x2
DEBUG APP1 at base 0x2
DEBUG Length: 0x17 0x7C
DEBUG Code: Exif
DEBUG Decrement base by 2 to get to pre-segment header (for compatibility with later code)
DEBUG Endian format is I (Intel)
DEBUG IFD 0 (Image) at offset 8:
DEBUG ImageDescription: (0x010E) ASCII=Gran Turismo 5 @ 170
DEBUG Make: (0x010F) ASCII=Polyphony Digital Inc. @ 186
DEBUG Model: (0x0110) ASCII=Gran Turismo 5 @ 210
DEBUG Orientation: (0x0112) Short=Horizontal (normal) @ 54
DEBUG XResolution: (0x011A) Ratio=72 @ 226
DEBUG YResolution: (0x011B) Ratio=72 @ 234
DEBUG ResolutionUnit: (0x0128) Short=Pixels/Inch @ 90
DEBUG Software: (0x0131) ASCII=PMB Service Uploader @ 242
DEBUG DateTime: (0x0132) ASCII=2012:06:23 08:24:05 @ 264
DEBUG YCbCrPositioning: (0x0213) Short=Co-sited @ 126
DEBUG Copyright: (0x8298) ASCII=TM&Copyright (C) 20, ... ] @ 284
DEBUG ExifOffset: (0x8769) Long=340 @ 150
Traceback (most recent call last):
File "./EXIF.py", line 131, in
main()
File "./EXIF.py", line 99, in main
data = process_file(img_file, stop_tag=stop_tag, details=detailed, strict=strict, debug=debug)
File "/Users/bob/src/exif-py/exifread/init.py", line 204, in process_file
hdr.dump_ifd(ifd, ifd_name, stop_tag=stop_tag)
File "/Users/bob/src/exif-py/exifread/classes.py", line 238, in dump_ifd
logger.debug('%s SubIFD at offset %d:', ifd_info[0], values[0])
IndexError: list index out of range

Exception while handling image from Nikon camera

Traceback (most recent call last):
  File "testexif.py", line 27, in <module>
    exif = process_file(StringIO(filedata))
  File "/usr/local/lib/python2.7/site-packages/exifread/__init__.py", line 221, in process_file
    hdr.decode_maker_note()
  File "/usr/local/lib/python2.7/site-packages/exifread/classes.py", line 381, in decode_maker_note
    tag_dict=makernote.NIKON_NEW, relative=1)
  File "/usr/local/lib/python2.7/site-packages/exifread/classes.py", line 229, in dump_IFD
    printable = tag_entry[1](values)
  File "/usr/local/lib/python2.7/site-packages/exifread/tags/makernote.py", line 38, in nikon_ev_bias
    a = seq[0]
TypeError: unsupported operand type(s) for -: 'int' and 'str'

BTW, the seq array I dumped here is

seq = 'Descriptio'

dscn7397

Not a bug, just a question about the GPS tags

Hi

First of all, thank you for this nice python module! I am new to EXIF data, so this is probably a very simple question. I have been having some trouble understanding the GPS tag information.

These are the GPS tags I am getting:
{'GPS GPSLatitude': (0x0002) Ratio=[5, 5685623/100000, 0] @ 1422}
{'GPS GPSAltitudeRef': (0x0005) Byte=0 @ 1402}
{'GPS GPSLongitudeRef': (0x0003) ASCII=E @ 1378}
{'GPS GPSLatitudeRef': (0x0001) ASCII=N @ 1354}
{'GPS GPSLongitude': (0x0004) Ratio=[23, 2763129/50000, 0] @ 1446}
{'GPS GPSAltitude': (0x0006) Ratio=648 @ 1470}

I would like to decode the GPS information into the coordinates that you can put into google maps. I can see the N for North and the E for East but the rest I don't really understand.

Thanks a lot :)!

webp support

cwebp -metadata all -q 80 image.jpg -o image.webp will retain EXIF information in WebP files converted from JPEG however exif-py doesn't seem able to read:

> ./EXIF.py image.webp
Opening: i.webp
No EXIF information found

performance patch dump_IFD method - 4 x faster

1) Oryginal version
569 files
Elapsed: 256.631432847 sec.

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 34688490   78.455    0.000   78.455    0.000 {method 'read' of 'file' objects}
 34679370   47.406    0.000  201.507    0.000 classes.py:63(s2n)
     2280   45.234    0.020  256.573    0.113 classes.py:123(dump_IFD)
 34679370   43.470    0.000   46.510    0.000 utils.py:40(s2n_intel)
 34687920   34.439    0.000   34.439    0.000 {method 'seek' of 'file' objects}

2) After patch
569 files
Elapsed: 72.3322822533 sec.   >>> 3,5 * times faster than oryginal <<<

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     2280   29.573    0.013   71.974    0.032 classes.py:151(dump_IFD)
 34617810   25.082    0.000   40.219    0.000 classes.py:66(s2n)
 34617810   14.868    0.000   15.137    0.000 utils.py:40(s2n_intel)
 14247152    1.313    0.000    1.313    0.000 {method 'get' of 'dict' objects}


@@ -47,13 +47,14 @@
 class ExifHeader:
     """
     Handle an EXIF header.
     """
     def __init__(self, file, endian, offset, fake_exif, strict, debug=0, detailed=True):
-        self.file = file
+        file.seek(0)
+        self.file_buff = file.read(8000)
         self.endian = endian
         self.offset = offset
         self.fake_exif = fake_exif
         self.strict = strict
         self.debug = debug
         self.detailed = detailed
@@ -66,14 +67,14 @@

         Usually this offset is assumed to be relative to the begining of the
         start of the EXIF information.
         For some cameras that use relative tags, this offset may be relative
         to some other starting point.
         """
-        self.file.seek(self.offset + offset)
-        slice = self.file.read(length)
+        read_from = self.offset + offset
+        slice = self.file_buff[read_from:read_from + length]
         if self.endian == 'I':
             val = s2n_intel(slice)
         else:
             val = s2n_motorola(slice)
         # Sign extension ?
         if signed:
@@ -174,14 +175,14 @@
                 if field_type == 2:
                     # special case: null-terminated ASCII string
                     # XXX investigate
                     # sometimes gets too big to fit in int value
                     if count != 0: # and count < (2**31):  # 2E31 is hardware dependant. --gd
                         try:
-                            self.file.seek(self.offset + offset)
-                            values = self.file.read(count)
+                            values = self.file_buff[self.offset + offset: self.offset + offset + count]
                             # Drop any garbage after a null.
                             values = values.split('\x00', 1)[0]
                         except OverflowError:
                             values = ''
                 else:
@@ -237,14 +238,14 @@
                                                             field_type,
                                                             values, field_offset,
                                                             count * typelen)
                 logger.debug(" %s: %s", tag_name, repr(self.tags[ifd_name + ' ' + tag_name]))

             if tag_name == stop_tag:
-                break
+        # for

Serializing the exif info

Is there some way of converting the dictionary returned by process_file in to a plain Python data structure? I would like to be able to serialize it to JSON in order to store it a database.

Add Flir tags as enhancements

Hello,

I couldn't find out how to extend the library. I would like to have the tags below added :

http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/FLIR.html

This would allow processing infrared images with Python.

Edit: Started here: https://github.com/ericoporto/exif-py/blob/develop/exifread/tags/makernote/flir.py

Edit2:
in the file exifread__init__.py, in the following lines:

...
# APP1
logger.debug("  APP1 at base 0x%X", base)
logger.debug("  Length: 0x%X 0x%X", ord_(data[base + 2]),
             ord_(data[base + 3]))
logger.debug("  Code: %s", data[base + 4:base + 8])
if data[base + 4:base + 8] == b"Exif":
    logger.debug("  Decrement base by 2 to get to pre-segment header (for compatibility with later code)")
    base -= 2
    break
increment = increment_base(data, base)
logger.debug(" Increment base by %s", increment)
base += increment
...

Why is there a break there? If my image has more than one APP1 entry (0xFFE1), I don't get what should the code do...

Edit3: I got the APP1 chunks, in my code, but I couldn't find out how to apply Phyl Harvey's table, what the index, what his FLIR FFF Tags are supposed to represent. From his code I understood that I have to first combine the chunks, which I did (didn't pushed yet), but I don't know if these are address, or I should interpret as multiple IFDs

[minor] update documentation

README still says import EXIF, think this should be changed to import exifread.

Thanks for the great tool ๐Ÿ‘

Could you fix this error please?

I use this library on django and lately I am getting the following error:

File "/usr/lib/python2.6/site-packages/exifread/init.py", line 221, in process_file
hdr.decode_maker_note()

File "/usr/lib/python2.6/site-packages/exifread/classes.py", line 401, in decode_maker_note
tag_dict=makernote.CASIO)

File "/usr/lib/python2.6/site-packages/exifread/classes.py", line 232, in dump_IFD
for i in values:

TypeError: 'NoneType' object is not iterable

I would appreciate if you could look into it.

Thanks!

EXIF not read from iPhoto processed files

EXIF.py cannot read exif information from files, that were processed through iPhoto or something like that (I'm not an apple user, but the photos I have with this problem are frome one). The EXIF.py output is just:

No EXIF information found

I found fix for that: http://www.dudek.org/blog/154
And this version is working again properly. It may be interesting to extract the patch and apply it in this EXPIF.py version as well.

TypeError: unorderable types: int() <= str()

My gut says this is related to issue #30 (which I reproduced locally as well).

I am running latest from development and get the following for the image below. Like in issue #30 I was mass processing a bunch of images that mostly work. Most are mine but at one point I had to recover a bunch of images after a drive failure and my present efforts are trying to deal with that. This particular image is not mine.

altendky@lt:~/ex$ git --git-dir=/tmp/exif-py/.git pull
Already up-to-date.
altendky@lt:~/ex$ git --git-dir=/tmp/exif-py/.git rev-parse HEAD
bce80b49d1b9ac7a178e6cae19416ba3712109f5
altendky@lt:~/ex$ python3
Python 3.3.2+ (default, Oct  9 2013, 14:50:09) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import exifread
>>> exifread.__version__
'2.0.0'
>>> f = open('ex.jpg', 'rb')
>>> tags = exifread.process_file(f)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.3/dist-packages/ExifRead-2.0.0-py3.3.egg/exifread/__init__.py", line 209, in process_file
    hdr.dump_ifd(exif_off.values[0], 'EXIF', stop_tag=stop_tag)
  File "/usr/local/lib/python3.3/dist-packages/ExifRead-2.0.0-py3.3.egg/exifread/classes.py", line 226, in dump_ifd
    printable = tag_entry[1](values)
  File "/usr/local/lib/python3.3/dist-packages/ExifRead-2.0.0-py3.3.egg/exifread/utils.py", line 19, in make_string
    if 32 <= c and c < 256:
TypeError: unorderable types: int() <= str()

ex

Python 3 compatibility

Could the library be updated to be python 3 compatible? I'd like to use it for a project of mine, but I don't want to lose python 3 compatibility.

Using the script in python

Hi, this question my be very trivial, but I couldn't find an answer to it anywhere else - how do I use your code from within python? (while keeping the files separate)

Don't work on import

Hello, when I use the program exif-py on bash (installed) and use it on a picture that has exif data with debug mode I can see JPEG format recognized data[0:2] == '0xFFD8'. so it shows all EXIF information

but if I do a git clone (fix the relative imports) and use it on debug I got DEBUG File format not recognized. WARNING No EXIF information found

On both tests I use the same image file 'test.jpg' so I don't understand why the fact to use it as standalone or library change the ways it reads (I did'nt changed the test.jpb file meanwhile)

Thanks in advance.

Panasonic

Could you add makernote decoding for Cameras from Panasonic as you did for Canon and so ?

EXIF output format?

I don't this is a bug, but I wonder if you can explain the below....

All the EXIF tags I read are returned in formformat:

'': <hex_number> = @
For instance:

'Image Copyright': (0x8298) ASCII=Transport for London @ 188

Can you explain what the hex and the @ fields are for? I can parse them out - but just interested...

import failure on python 2.6

Using python 2.6.6 on centos 6 with checkout of master via commit f9667bb

Traceback (most recent call last):
  File "run.py", line 5, in <module>
    import exifread
  File ".../venv/lib/python2.6/site-packages/exifread/__init__.py", line 3, in <module>
    from .classes import *
  File ".../venv/lib/python2.6/site-packages/exifread/classes.py", line 4, in <module>
    from .tags import *
ImportError: No module named tags

exifread supports not panasonic's RW2 files

The panasonic RW2 file begins with 'IIU\x00' and not with 'II*\x00' or 'MM\x00'.
line 30,31,32 of init.py in directory exifread are:
30 # determine whether it's a JPEG or TIFF
31 data = f.read(12)
32 if data[0:4] in [b'II*\x00', b'MM\x00*']:
if you change line 32 to:
if data[0:4] in [b'II*\x00', b'MM\x00*', b'IIU\x00']:
exifread runs also with Panasonic's RW2

Doesn't give any tag for this image

Code used:

>>> import exifread
>>> f = open('ctx.jpg', 'rb')
>>> tags = exifread.process_file(f)
>>> print tags
{}

While this worked for other images, it did not work on this one. Any help?

Testing the library

I recently forked the project here: https://github.com/rshk/exif-py/ and started some refactoring/clean up (pull requests coming soon), in order to make it installable from pypi and more efficient / maintainable.

I was wondering: what do you use for testing? Do you have a collection of jpegs along with known tag data? The library is seriously missing some unittests; I'd like to write some, but I miss the data..

Problem with some JPEG files from Olympus PEN

Hello,

I use this libarary to rename/redate some JPEG file from various cameras just like in my recipe: http://code.activestate.com/recipes/550811-jpg-files-redater-by-exif-data/ (of course now I use exifread instead of EXIF). It works well with photos from my Canon camera but with some photos from Olympus camera it raises exception:

Exception: <type 'exceptions.IndexError'>: string index out of range
Traceback (most recent call last):
  File "c:\tools\pyscripts\scripts\exif_redater.py", line 60, in redate_by_exif
    tags = exifread.process_file(f)
  File "C:\Python27\lib\site-packages\exifread\__init__.py", line 221, in process_file
    hdr.decode_maker_note()
  File "C:\Python27\lib\site-packages\exifread\classes.py", line 392, in decode_maker_note
    tag_dict=makernote.OLYMPUS)
  File "C:\Python27\lib\site-packages\exifread\classes.py", line 229, in dump_IFD
    printable = tag_entry[1](values)
  File "C:\Python27\lib\site-packages\exifread\tags\makernote.py", line 256, in olympus_special_mode
    if v[0] not in mode1 or v[2] not in mode2:
IndexError: string index out of range

I will try to attach such file but is is quite big (almost 3MiB) and I don't know if github changes it. It gives such SHA1 sum:

1107a75242c828b8e9cae8f25d18134cc9877ce2 *P8237937.JPG

p8237937

Error on unicode metadata

I found an exception. This line:

printable = str(values[0:20])[0:-1] + ", ... ]"

throws an exception when the string contains unicode characters. I fixed this issue on my branch. I'll send you a pull request.

LensData not displayed correctly

Hi, I want to identify the lenses that are used for making sets of photos via the exif tags. Since the PIL exif tool apparently misses all lens-related tasgs I will have to use some other tool, and your script seems to work quite nicely.

For some reason however the LensData is just wrong. I used an AF-S DX Nikkor 35mm f/1.8G lens for a picture and the LensData tag reads
MakerNote LensData (Undefined): [48, 50, 48, 52, 194, 81, 72, 235, 0, 171, 31, 120, 91, 185, 215, 158, 162, 51, 140, 220, 255, 254, 60, 67, 141, 163, 81, 151, 104, 217, 219, 115, 222]

This tag doesn't correspond either to my lens nor to any other lens as per the library found here http://www.rottmerhusen.com/objektives/lensid/thirdparty.html

Any ideas what's wrong?

Why more accuracy from OSX's "Preview" application?

For a particular image, exif-py tells me the latitude is:

EXIF GPS GPSLatitude, [31, 27, 2147/100]

So 31 degrees, 27 minutes, 21.47 seconds.

But if I view the GPS info from Preview in OSX, it tells me 21.468 seconds. An additional digit of accuracy.

Can you help me understand why?

Image and screenshot of exif-py and preview attached.

why_more_accurate
img_0234

UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9'

Here's the image that causes the problem.

This seems to be a regression from 1.4.2 where process_file does not blow up on this image.

DEBUG JPEG format recognized data[0:2]=0xFFD8
DEBUG data[2]=0xFF data[3]=0xE1 data[6:10]=Exif
DEBUG Segment base 0x2
DEBUG APP1 at base 0x2
DEBUG Length: 0x34 0x24
DEBUG Code: Exif
DEBUG Decrement base by 2 to get to pre-segment header (for compatibility with later code)
DEBUG Endian format is I (Intel)
DEBUG IFD 0 (Image) at offset 8:
DEBUG ImageDescription: (0x010E) ASCII=Arion ater @ 158
DEBUG Make: (0x010F) ASCII=Canon @ 170
DEBUG Model: (0x0110) ASCII=Canon EOS-1D Mark IV @ 176
DEBUG XResolution: (0x011A) Ratio=240 @ 198
DEBUG YResolution: (0x011B) Ratio=240 @ 206
DEBUG ResolutionUnit: (0x0128) Short=Pixels/Inch @ 78
DEBUG Software: (0x0131) ASCII=Adobe Photoshop Lightroom 4.0 (Macintosh) @ 214
DEBUG DateTime: (0x0132) ASCII=2012:06:23 16:19:48 @ 256
DEBUG Artist: (0x013B) ASCII=Robert Muckley @ 276
Traceback (most recent call last):
File "./EXIF.py", line 131, in
main()
File "./EXIF.py", line 99, in main
data = process_file(img_file, stop_tag=stop_tag, details=detailed, strict=strict, debug=debug)
File "/Users/bob/src/exif-py/exifread/init.py", line 204, in process_file
hdr.dump_ifd(ifd, ifd_name, stop_tag=stop_tag)
File "/Users/bob/src/exif-py/exifread/classes.py", line 227, in dump_ifd
printable = str(values)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in position 10: ordinal not in range(128)

Installing module as subfolder fails to import

I'm using Python 2.7.3 on Ubuntu.

I have sample program that looks like this:

from exifpy import exifread
path_name = "CAM00124.jpg"
f = open(path_name, 'rb')
tags = exifread.process_file(f)

On the same folder level, I've checked out exif-py using git into a folder called exifpy.

However this doesn't work because of the following error:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    from exifpy import exifread
  File "/home/ngeor/sandbox/exif/exifpy/exifread/__init__.py", line 2, in <module>
    from .classes import *
  File "/home/ngeor/sandbox/exif/exifpy/exifread/classes.py", line 7, in <module>
    from .tags import *
  File "/home/ngeor/sandbox/exif/exifpy/exifread/tags/__init__.py", line 5, in <module>
    from .exif import *
  File "/home/ngeor/sandbox/exif/exifpy/exifread/tags/exif.py", line 5, in <module>
    from exifread.utils import make_string, make_string_uc
ImportError: No module named exifread.utils

I fixed it easily by editing tags/exif.py and tags/makernote.py and telling them to reference utils using a relative path:

diff --git a/exifread/tags/exif.py b/exifread/tags/exif.py
index 989a890..4d8bd58 100644
--- a/exifread/tags/exif.py
+++ b/exifread/tags/exif.py
@@ -2,7 +2,7 @@
 Standard tag definitions.
 """

-from exifread.utils import make_string, make_string_uc
+from ..utils import make_string, make_string_uc

 # Main Exif tag names
 EXIF_TAGS = {
diff --git a/exifread/tags/makernote.py b/exifread/tags/makernote.py
index 7e3e143..1adc7be 100644
--- a/exifread/tags/makernote.py
+++ b/exifread/tags/makernote.py
@@ -2,7 +2,7 @@
 Makernote tag definitions.
 """

-from exifread.utils import make_string, make_string_uc, Ratio
+from ..utils import make_string, make_string_uc, Ratio

 from . import makernote_canon as canon

Normally I would create a pull request for this but:

  1. it is too small of a fix
  2. I don't know what implications this could have for different types of install
  3. I don't know what implications this could have for different Python versions

EXIF data not detected in some files

In the process of handling EXIF orientation information in my app, I discovered that exif-py can't detect EXIF information in some files. Specifically, the EXIF orientation test files located at https://github.com/ianare/exif-py show as having no EXIF information in exif-py:

Mithril:rgb mitch$ ./EXIF.py ~/Pictures/exif-orientation-examples/Portrait_6.jpg 
/Users/mitch/Pictures/exif-orientation-examples/Portrait_6.jpg:
No EXIF information found

Compare to the output of ImageMagick's identify:

Mithril:rgb mitch$ identify -format "%[EXIF:*]" ~/Pictures/exif-orientation-examples/Portrait_6.jpg 
exif:ExifImageLength=450
exif:ExifImageWidth=600
exif:ExifOffset=90
exif:Orientation=6
exif:ResolutionUnit=2
exif:XResolution=72/1
exif:YResolution=72/1

TypeError: unsupported operand type(s) for +: 'int' and 'str'

I was processing a large list of image files and I was getting the error 'TypeError: unsupported operand type(s) for +: 'int' and 'str''. This is the complete output:

Opening: /Users/familypc/Desktop/culprit.jpg
Traceback (most recent call last):
  File "./EXIF.py", line 132, in <module>
    main()
  File "./EXIF.py", line 100, in main
    data = process_file(file, stop_tag=stop_tag, details=detailed, strict=strict, debug=debug)
  File "/private/tmp/exif-py/exifread/__init__.py", line 201, in process_file
    hdr.dump_IFD(exif_off.values[0], 'EXIF', stop_tag=stop_tag)
  File "/private/tmp/exif-py/exifread/classes.py", line 124, in dump_IFD
    entries = self.s2n(ifd, 2)
  File "/private/tmp/exif-py/exifread/classes.py", line 71, in s2n
    self.file.seek(self.offset + offset)
TypeError: unsupported operand type(s) for +: 'int' and 'str'

I was able to track the issue to a particular file:
culprit

That file was an Photoshop export from a Nikon RAW image (*.nef) to jpg. I don't know what's wrong with it. I have other files exported the same way and I didn't have issues. The files is perfectly fine because I can open it.

Rational value 26 not being read correctly (Lat/Long/ImgDirection)

On at least some of the attributes, a rational value of 26 is being read as a 0 by exifread 2.1.2 . This appears to be the case with latitude and longitude, degrees and minutes as well as ImgDirection. When the latitude or longitude degrees and/or minutes have a true value of 26, they are being converted to 0 when read by exifread. Exifread will read 26 in the minutes, but only if the seconds is 0. Looks to be a bug in BOTH latitude and longitude. This also appears to be an issue with ImgDirection, and I am thinking it impacts other rational values as well. Seconds in latitude and longitude appears to work correctly. Other EXIF reader software interpret the lat/long and ImgDirection correctly, so it doesn't appear to be an issue with the photos themselves.

Release v2.0 already!

Current release 1.4.2 does not work with python 3.
Development branch works, but has been idle for more than 6 months. If it's not going to change anytime soon, it would be great to release it on pypi.

That would avoid a lot of headache such as #35.
Thanks!

Standardization

Not an issue, just clarification.

I've only got a Canon to mess around with, and as such I'm curious about standardization between make and model of cameras. Can I always expect the tags for Image and EXIF to be present across files from Canon, Nikon, Sony, etc.?

Does stop_tag=`EXIF DateTimeOriginal` work?

i have tried many variations of

tags = exifread.process_file(f, stop_tag=EXIF DateTimeOriginal)
but
tags.items()
is always empty.

There are tags, when stop_tag parameter is omitted, it returns everything, including 'EXIF DateTimeOriginal'.

exifread reaturn empty tags object

Hi,

I tried your ExifRead on my Synology on two different images, that both contain tags if read with exiftool.

What details can I provide you?

Linux Synology_NAS 3.2.40 #3810 SMP Wed Nov 6 05:13:41 CST 2013 armv7l GNU/Linux synology_armadaxp_ds214+

Python 3.3.2 (default, Dec 23 2013, 16:12:02)
[GCC 4.6.4] on linux

EXIF.py Ver 1.4.2

BR
Nippey

Orientation strings are incorrect

Two of the orientation strings used by exif-py are incorrect. The strings are:

>>> EXIF_TAGS[0x112][1]
{1: 'Horizontal (normal)', 2: 'Mirrored horizontal', 3: 'Rotated 180', 4: 'Mirrored vertical', 5: 'Mirrored horizontal then rotated 90 CCW', 6: 'Rotated 90 CW', 7: 'Mirrored horizontal then rotated 90 CW', 8: 'Rotated 90 CCW'}

However, if you compare those strings to the information and diagrams describing EXIF orientation here, you will see that two of them are incorrect. Specifically, 8 and 6 are reversed.

Python 3 support?

I whacked at it until it seems to run under Python 3, but I didn't make the code conditional, so I have a replacement version... any interest? I'm not a git user, so I just grabbed the file, and edited. Tell me where to email the file, if interested. Was pretty straightforward. Otherwise I'll just put it on my web site, and it will acquire bit-rot...

My goal was to extract GPS data, so I added --gps option to print only that.

FocalLenght not displayed correctly

Hi. I've checked a lot of my photos and some of them give wrong FocalLength exif. Photos have FocalLength 105mm, but exif-py displays it like '2/5'.
Camera - Nikon D300, lens - 28-300mm f/3.5-5.6g ed vr af-s
Python 2.7.5, exifread 1.4.2, Windows 7

bug1
bug2

Test case:

import exifread
import os

BUG1 = 'bug1.jpg'

FOCAL_LENGTH = 'EXIF FocalLength'

f = open(BUG1)
tags = exifread.process_file(f, debug=True)
print '{0} - {1}'.format(BUG1, tags[FOCAL_LENGTH])

Output:

bug1.jpg - 2/5

Non-image file formats do not work

The MOV files from my 7d and the MP4, THM, and LRV files from my gopro all result in empty lists with no exceptions thrown. Interestingly, the THM files from my 7d are fine. All files tested are correctly read by exiftool.

Cannot seem to read EXIF data from PNGs

Seems as though it cannot read EXIF data from PNGs

$ EXIF.py --debug /tmp/1375-1.png
INFO   Opening: /tmp/1375-1.png
DEBUG  File format not recognized.
WARNING No EXIF information found

With other EXIF viewing/editing tools I can see the EXIF data in the PNG referenced above.

Performance with no details

There is a performance hit when you have details turned off, as you don't currently send in the details value into the ExifHeader instance, so it is always True. So line 181 of 'exifread__init__.py' is currently

    hdr = ExifHeader(f, endian, offset, fake_exif, strict, debug)

and it should be:

    hdr = ExifHeader(f, endian, offset, fake_exif, strict, debug, details)

Add support for ricoh GR MakerNote

Hi, support for Ricoh GR Makernote would be greatly appreciated - everyhing seems to be described here:
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/Ricoh.html

EDIT: Following examples from the exifread/tags/makernote folder, for example olympus.py, I've set up a ricoh.py file which looks like the following, and I import it in the __init__.py file with the from . import ricoh line. However, I cannot find what offset to use in the exifread/classes.py file, in the dump_ifd function - each maker seems to have a custom offset in that function, and I cannot link it to their respective tagnames pages.

if 'RICOH' in make:
    self.dump_ifd(**note.field_offset**, 'MakerNote',
                  tag_dict=makernote.ricoh.TAGS, verbose=False)
"""
Makernote (proprietary) tag definitions for Ricoh.

http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Ricoh.html
"""
from exifread.utils import make_string

TAGS = {
    0x0001: ('MakerNoteType', ),
    0x0002: ('FirmwareVersion', ),
    0x0005: ('InternalSerialNumber', ),
    0x1000: ('InternalSerialNumber', {
        2: 'JPG',
        3: 'DNG'
    }),
    0x1002: ('DriveMode', {
        0: 'Single-frame',
        1: 'Continuous ', 
        8: 'AF-priority Continuous', 
    }),
    0x1009: ('MacroMode', {
        0: 'Off',
        1: 'On'
    }),
}

string index out of range

version = '1.4.1'
When I read a photo from my iPhone, it happens process_file line 66. Most of them look ok but it breaks at one file so far. In my debug, each variables are like this. I know the information is not sufficient, but hope that this can give you little bit of clue.

data
??/
len(data)
5
base
2
so data[base+3] breaks since it's string out of range

def process_file( .........

    # Big ugly patch to deal with APP2 (or other) data coming before APP1
    f.seek(0)
    # in theory, this could be insufficient since 64K is the maximum size--gd
    data = f.read(base + 4000)
    # base = 2
    while 1:
        logger.debug(" Segment base 0x%X", base)
        if data[base:base+2] == '\xFF\xE1':
            # APP1
            logger.debug("  APP1 at base 0x%X", base)
            logger.debug("  Length: 0x%X 0x%X", ord(data[base+2]),
                         ord(data[base+3])) <---- here!
            logger.debug("  Code: %s", data[base+4:base+8])

global name 'Ratio' is not defined, happened after EXIF.py is split into several modules

Traceback Info

exifread.process_file(open('D:\test.NEF', 'rb'))

Traceback (most recent call last):
File "<pyshell#2>", line 1, in
exifread.process_file(open('D:\test.NEF', 'rb'))
File "D:\Python27\lib\site-packages\exifread__init__.py", line 229, in process_file
hdr.decode_maker_note()
File "D:\Python27\lib\site-packages\exifread\classes.py", line 396, in decode_maker_note
tag_dict=makernote.NIKON_NEW, relative=1)
File "D:\Python27\lib\site-packages\exifread\classes.py", line 269, in dump_IFD
printable = tag_entry1
File "D:\Python27\lib\site-packages\exifread\tags\makernote.py", line 48, in nikon_ev_bias
r = Ratio(a, b)
NameError: global name 'Ratio' is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.