# How to develop a VSE file format importer for DNG + CR2 image files?

This question isn't about the usual workflow (batch convert to a readable format).
Instead I'm looking for a solution to import DNG + CR2 RAW files directly into blender (without decoding/converting the files again).

Reason: Saving Time and Resources.

Why: Because we all have better things to do besides batching conversions :)

Update: @Sambler : How do you compile blender? With make or make full? Somehow mine can't display the dng-raw. I always get a blank/transparent preview with in a thumbnail resolution (256x). Please read further down below the last comments for more details. Many thanks in advance.

• @ all developer - how to start developing this feature? – chris Jul 4 '16 at 23:48
• DNG SDK + Infos link – chris Jul 5 '16 at 0:17
• RAW Format discussion – chris Jul 5 '16 at 0:24
• I doubt strongly that your time is going to be better spent doing demosaicing on the fly... Even if you were to bring a sequence of cr2 or DNGs into the VSE, you'd spend a lot of time caching to get some kind of decent playback... If you are in Linux give Natron (or Nuke) a try, it allows you to import cr2 sequences directly using the default config, but you can also use tuttleOFX's rawreader that gives you a lot more control for the debayering... It is predictably slow... Decoding raw files is not trivial and does require a lot of processing power... – cegaton Jul 5 '16 at 6:52
• – Samoth Jul 5 '16 at 10:13

First off blender seems to read CR2 files without issue, at least with the few samples I downloaded. It could read more data, that is blender loads one of the samples I have in the natural resolution, while the OpenImageIO file viewer automatically rotates it to match the rotation of the camera. Blender's file browser will filter out CR2 files by default but if you disable the filter and select a CR2 file it will read it. Adding CR2 to the list of available file formats is all that is needed here. Once loaded blender says the CR2 file has a TIFF file_format. This would be a minor change that should be accepted as a bug report, test with a variety of files to make sure first.

For DNG, blender only sees the thumbnail - or the thumbnail is found first and mistakenly read as the image data. (if you have one without a thumbnail try it).

From what I have read, DNG is a variation of TIFF/EP so I see two options, first is to adjust blender's TIFF reading code, the other is to use OpenImageIO to read DNG files. The image viewer built as part of OpenImageIO can read the sample DNG files that I have found, so this may be a viable option for adding support. For reference using OpenImageIO to read PSD files was added here, it is possible that this code added for PSD may only need minor changes to also work with DNG.

I'm not sure this will be considered an acceptable bug report as it is adding support for a new file format. You may want to add DNG image support to the requests page or you could talk to some of the developers at #blendercoders on IRC to see if someone is interested in adding this image support, unless you want to submit a patch for it yourself.

Update:

A quick test with just adding to the file suffix list shows that telling blender to use OpenImageIO to open DNG and CR2 files works. Simply adding the file suffixes to the code used for PSD files allows DNG and CR2 files to be opened. As mentioned at the start this brings in CR2 files rotated based on image metadata the same as opening the images using iv. Images opened this way report their file_format as JPEG so further work to distinguish DNG and CR2 files from PSD and JPEG will be needed but should be minimal.

• thank you - great answer! I already tried the CR2 with success. Now I'm dealing with the DNG Thumbnail. I'll try your suggested work around. Keep you updated. – chris Jul 5 '16 at 13:10
• Update: During building I encountered some issues: (blender.stackexchange.com/questions/57249/…) – chris Jul 5 '16 at 14:02
• When I load a DNG Sequence blender suddenly shuts down. Could you try the footage if it's working on your blender version? Which version do you have? Thanks – chris Jul 6 '16 at 19:40
• I don't have any trouble with your sequence. This is your first build? are you sure it works with other sequences? I built using the git master from a few days ago (4/7) and have oiio 1.6.15 which was released 6 days ago. Try running blender in gdb and do a backtrace when it stops, this might give a clue as to where it fails. – sambler Jul 7 '16 at 3:51
• thanks for the note. yeah, I'm first build virgin :) Currently I'm having issues related to libtiff4/5. Do you know how to force selecting a version? Package libtiff-dev is a virtual package provided by: libtiff4-dev 3.9.6-11 libtiff5-dev 4.0.3-12.3+deb8u1 You should explicitly select one to install. E: Package 'libtiff-dev' has no installation candidate ERROR! apt-get failed to install requested packages, exiting. libtiff5-dev 4.0.3-12.3+deb8u1 is installed already, beside libtiff4. libtiff4-dev is not installed. Any suggestion how to move on? – chris Jul 8 '16 at 11:30