Author Topic: How much Image I need to read to get the EXIF data?  (Read 125 times)

knipser

  • Newbie
  • *
  • Posts: 3
How much Image I need to read to get the EXIF data?
« on: March 15, 2019, 09:23:54 AM »
Firstly, I read the FAQ, honestly! But no answer there...

How much Image I need to read the EXIF data? I thought the EXIF data is very small, but seems not after testing.  I have a 25Mb *.ARW file and I need to get the first 150Kb to read the EXIF.

Is that correct? And is that the same with TIFF and JPG? Or what is the best way to get the minimum amount of data?

This is what I did, and I like to get comments if I did something wrong or if it can be improved:

      
Code: [Select]
file = open('test.arw', 'rb')
chunk = file.read(150000)
file.close()

f = open('file.arw', 'wb')
f.write(chunk)
f.close()

exisearch = "exiftool -json -ImageSize file.arw"
mod = os.popen(exisearch).read()

# ...and so on...

file.read(140000) is already too small, so the bare minimum is somewhere between 140.000 and 150.000

And another question is, does it even make sense? I read data from an SD drive and not from file upload. Right now the time to read the 150Kb chunk is 0.77s - and the full 25Mb takes about 1s. Feels a bit that I am on the wrong track.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: How much Image I need to read to get the EXIF data?
« Reply #1 on: March 15, 2019, 09:28:37 AM »
For TIFF-based files like ARW, the EXIF may be anywhere in the file.  Use the exiftool -htmldump option to see where it is located in a specific file.

For JPEG images, EXIF comes before the image, so typically only a few 64kB blocks need to be read.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).