Git Product home page Git Product logo

Comments (2)

cytrinox avatar cytrinox commented on June 26, 2024

FYI, https://github.com/dnglab/dnglab has full support for CR3 Raw Burst Frame extraction inluding metadata and CTMD.

from canon_cr3.

koenkooi avatar koenkooi commented on June 26, 2024

I did this to get me far enough with my R8 CR3s:

Mac-Studio:canon_cr3 koen$ git diff
diff --git a/CRaw3/TiffIfd.py b/CRaw3/TiffIfd.py
index 8d2f71e..136b27b 100644
--- a/CRaw3/TiffIfd.py
+++ b/CRaw3/TiffIfd.py
@@ -4,7 +4,10 @@ from collections import namedtuple, OrderedDict
 from binascii import hexlify
 
 def getShortLE(d, a):
- return unpack('<H',(d)[a:a+2])[0]
+  if len(d) >1:
+    return unpack('<H',(d)[a:a+2])[0]
+  else:
+      return 0
 
 def getLongLE(d, a):
  return unpack('<L',(d)[a:a+4])[0]
diff --git a/parse_cr3.py b/parse_cr3.py
old mode 100644
new mode 100755
index f4041e3..bf3b722
--- a/parse_cr3.py
+++ b/parse_cr3.py
@@ -376,20 +376,23 @@ elif cr3[b'CNCV'].find(b'CanonCR3')>=0:
 
   #now we want raw data of TIFF entry 0x4016 (TIFF_CANON_VIGNETTING_CORR2), in subdir TIFF_MAKERNOTE, in CTMD record #7. We know it is type=4=long, little endian 32 bits
   ctmd_makernote7 = getIfd( b'CTMD', { 'type':7, 'tag':TiffIfd.TIFF_MAKERNOTE } ) #picture 0 by default
-  if TiffIfd.TIFF_CANON_VIGNETTING_CORR2 in ctmd_makernote7.ifd:
-    vignetting_corr2 = ctmd_makernote7.ifd[ TiffIfd.TIFF_CANON_VIGNETTING_CORR2 ]
-    r = Struct('<%dL' % vignetting_corr2.length).unpack_from( data, ctmd_makernote7.base+vignetting_corr2.value )
-  if options.verbose>1:
-    print(r)
+  if ctmd_makernote7:
+    if TiffIfd.TIFF_CANON_VIGNETTING_CORR2 in ctmd_makernote7.ifd:
+      vignetting_corr2 = ctmd_makernote7.ifd[ TiffIfd.TIFF_CANON_VIGNETTING_CORR2 ]
+      r = Struct('<%dL' % vignetting_corr2.length).unpack_from( data, ctmd_makernote7.base+vignetting_corr2.value )
+    if options.verbose>1:
+      print(r)
 
   cmt3 = getIfd( b'CMT3', None )
-  if TiffIfd.TIFF_MAKERNOTE_ROLLINFO in cmt3.ifd: # only in CSI_* files (raw burst mode)
-    rollInfoTag = cmt3.ifd[ TiffIfd.TIFF_MAKERNOTE_ROLLINFO ]
-    #print( rollInfoTag )
-    length, current, total = Struct('<%d%s' % (rollInfoTag.length, TiffIfd.tiffTypeStr[rollInfoTag.type-1])).unpack_from( data, cmt3.base+rollInfoTag.value )
-    #exif IFD for current picture in the roll
-    ifd = getIfd( b'CTMD', { 'picture':current, 'type':7, 'tag':TiffIfd.TIFF_MAKERNOTE } )
-    ifd.display()
+  if cmt3:
+    if TiffIfd.TIFF_MAKERNOTE_ROLLINFO in cmt3.ifd: # only in CSI_* files (raw burst mode)
+      rollInfoTag = cmt3.ifd[ TiffIfd.TIFF_MAKERNOTE_ROLLINFO ]
+      #print( rollInfoTag )
+      length, current, total = Struct('<%d%s' % (rollInfoTag.length, TiffIfd.tiffTypeStr[rollInfoTag.type-1])).unpack_from( data, cmt3.base+rollInfoTag.value )
+      #exif IFD for current picture in the roll
+      ifd = getIfd( b'CTMD', { 'picture':current, 'type':7, 'tag':TiffIfd.TIFF_MAKERNOTE } )
+      if ifd:
+          ifd.display()
     
   NT_SENSOR_INFO = namedtuple('sensorInfo','w h lb tb rb bb')
   sensorInfo = cmt3.ifd[ TiffIfd.TIFF_MAKERNOTE_SENSORINFO ]

from canon_cr3.

Related Issues (16)

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.