schoolpost / PiDNG

Create Adobe DNG RAW files using Python. Works with any Bayer RAW Data including native support for Raspberry Pi cameras.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RPICAM2DNG() not converting mode 2 High Quality Cam

dgcarr opened this issue · comments

Get the following error when trying to extract raw DNG from photos taken in mode 2 on rpi high quality camera
(raspistill --mode 2 -r -o test.jpg):
image

Traceback (most recent call last):
d.convert(im)
File "C:\Users\daggy\AppData\Roaming\Python\Python39\site-packages\pidng\core.py", line 267, in convert
rawFrame = self.process(image, process)
File "C:\Users\daggy\AppData\Roaming\Python\Python39\site-packages\pidng\core.py", line 232, in process
rawImage = self.extractRAW(input_file)
File "C:\Users\daggy\AppData\Roaming\Python\Python39\site-packages\pidng\core.py", line 195, in extractRAW
assert data[:4] == 'BRCM'.encode("ascii")
AssertionError

Can you send a link to this RAW image?

The reason for this error because even though you are using mode 2 RAW, the jpeg file is still creating a 4056x3040 sized image and therefore PiDNG assumes it is full size RAW. ( which is the correct assumption based the jpeg )

So two ways around this:

  1. Make the JPEG output the same dimensions as the RAW output ( so 2028x1520 )
  2. Edit the EXIF data of the jpeg and change the ImageWidth and ImageLength to 2028x1520
  3. Edit the PiDNG source and set the version variable to version 4.

    PiDNG/pidng/core.py

    Lines 178 to 183 in 30bee22

    if int(str(self.__exif__['Image ImageWidth'])) == 2028 \
    and int(str(self.__exif__['Image ImageLength'])) == 1520 \
    and ver == 3:
    ver = 4

So you could add a line and just set "ver = 4"