Native support for Nikon NEF and Canon CR2 RAW files

Native support for Nikon NEF and Canon CR2 RAW files

By | 2016-12-01T16:37:39+00:00 October 19th, 2015|Uncategorized|0 Comments

Recently a potential customer was kicking the tires of Gallery Server and noticed they weren’t getting thumbnail or web-optimized images from the raw NEF photos taken by their Nikon cameras. In fact, they couldn’t even add a NEF file to the gallery unless they selected the ‘allow all file types’ option on the Media Object Types page. They asked if this could be improved, so we dug into it and found there were actually two different ways to get great NEF support, including image generation, with just a bit of configuration.

We believe the first technique will work for other file types, too, such as Canon CR2 and other RAW file formats. At the end we touch on this and describe where we’re headed.

Nikon raw NEF images have native support in Gallery Server digital asset management


FIRST – Add the NEF mime type

Regardless of the method you choose, the first thing you need to do is tell Gallery Server that files with the NEF file extension are allowed in the gallery. This section actually applies to any file type you want to add to your gallery that isn’t already in the list of files on the Media Object Types page.

  1. Open your database administration tool. If using SQL Server, this generally means SQL Server Management Studio (SSMS). If using SQL CE, you can use SQLCE Toolbox. Insert a row into the gsp.MimeType table using this syntax:

    [gsp].[MimeType]([FileExtension], [MimeTypeValue], [BrowserMimeTypeValue]) VALUES ('.nef', 'image/x-nikon-nef', '')
  2. Recycle the IIS application pool or run iisreset at a command prompt to clear the web application cache.
  3. Navigate to the Media Object Types page in the site admin area of your gallery and enable the NEF file type:

    Enable the NEF file type on the Media Object Types page

  4. At this point you can upload NEF files to your gallery but they are treated as generic media assets because the .NET Framework is unable to generate images from them. It works but is not ideal:

Nikon raw NEF files treated as generic media assets in Gallery Server

Nikon raw NEF files treated as generic media assets in Gallery Server

Read on to get first class support for NEF files.

Method 1 – Use ImageMagick

ImageMagick is one of the third party open source components included in the Gallery Server Binary Pack. It adds support for generating JPG images from a variety of files, including PDF, TXT, EPS, PSD, and TIF. Turns out you can get ImageMagick to happily process NEF images, too.

  1. Install the Gallery Server Binary Pack. For this post, you only need convert.exe in the bin directory of the web application, so make sure you’ve done at least that. Instructions for installing it are included in a readme file in the download.
  2. Add NEF to the gallery setting named ImageMagickFileTypes. Use SSMS (if you’re using SQL Server) or SQLCE Toolbox (if using SQL CE) to open the gsp.GallerySetting table. Look for ALL records where SettingName=’ImageMagickFileTypes’. There will be at least two – one for the template gallery and one for your actual gallery:

    Add NEF file to the Gallery Setting ImageMagickFileTypes

  3. Add dcraw.exe to the bin directory. To keep things simple, the Gallery Server Binary Pack includes only the main ImageMagick utility convert.exe, which is fine for most scenarios. But now we need functionality in the supporting library dcraw.exe. This file is included with the full ImageMagick package and its version is matched with convert.exe, so if you are using the current version of convert.exe included in the binary pack (6.8.9), you need the matching version of dcraw that shipped with 6.8.9. Here’s a link: You’ll find it in the ImageMagick-6.8.9\VisualMagick\bin directory. If you’re using another version of convert.exe, be sure to get the matching version of dcraw.exe. Once you have it, pop it into the bin directory.

    dcraw.exe in the bin directory

  4. At this point you should be able to add NEF files to your gallery and get true thumbnail and web-optimized images for them as shown in the first screenshot above. If you have any trouble check out the gallery event log in the site admin area. If you can’t figure things out, try the next method.

Method 2 – Use the Nikon codec

Nikon provides a codec that, when installed on the web server, allows the .NET Framework to generate images and retrieve meta properties (e.g. Camera maker, model, date taken, etc) without any additional software. Gallery Server 3.2.1 is not able to extract the meta properties, but we are working to add support for this in version 4.0.

  1. Download and install the Nikon NEF Codec on the web server where your gallery is installed.
  2. That’s it. Your gallery should be able to handle NEF files like a champ!

What about Canon CR2 files? And other RAW files?

Canon does not provide a codec that runs on a Windows Server OS, so method 2 is out. But if ImageMagick is capable of processing a file, then it is theoretically possible to configure Gallery Server to delegate that work to ImageMagick to get thumbnails and web-optimized images. And a quick Google search reveals that ImageMagick can process CR2 files, so we believe the first method described above will work for CR2 and hopefully other RAW files.

In fact, that potential customer we mentioned at the beginning? They turned into a satisfied paying customer and used a combination of both methods above to get full image support for NEF, CR2, and DNG files. We have not yet confirmed the CR2 and DNG functionality ourselves, so your mileage may vary. We’ll be digging into this on our march to the next big release, so stay tuned.

Share this story

About the Author:

Founder and Lead Developer of Gallery Server

Leave A Comment

You must be logged in to post a comment.