New open-source img2nef utility: convert any image into a Nikon NEF RAW file


Long-time NR reader and contributor Horshack has released a new open-source img2nef utility that converts any image file into a Nikon NEF lossless-compressed RAW file. Here are the details:

Today I’m publishing my open-source img2nef utility, which converts any image file into a Nikon NEF lossless raw. The NEF can be used anywhere NEFs are supported, including in the camera itself. Here is the GitHub project page:

GitHub – horshack-dpreview/img2nef: Converts any image into a Nikon NEF lossless compressed raw

This is the code I wrote as part of my Nikon C2PA signing exploit (NR article and follow-up article). The NEF encoder is written in C, with all the supporting logic / command-line utility written in Python.

In addition to scientific/technical uses there are some practical applications as well. For example, Nikon MILCs have a multiple exposure feature that lets you specify an existing NEF as the first image of the composite. Normally the existing NEF would be an image taken with the camera but with img2nef you can use any image converted into a NEF, including computer-generated and AI images. Outside of the creative possibilities you can use this feature to create custom viewfinder overlays (ie, custom aspect ratio framing guides and/or display grids), where the “first” NEF of the composite is the overlay you create. This is because Nikon’s feature lets you view the first NEF as an overlay while you’re shooting, again as if you were creating a composite image.

To make it easy to create and use overlays I’ve written a utility named ‘createoverlay’ that lets you create any combination of aspect ratio framing guides and grid layouts as a PNG and then automatically convert that into an NEF for use in the camera. The documentation on my GitHub has all the details on how to use and apply these overlays. Here is a quick video showing an overlay in use:

This entry was posted in Nikon Software and tagged . Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • FCC disclosure statement: this post may contain affiliate links or promotions that do not cost readers anything but help keep this website alive. As an Amazon Associate, I earn from qualifying purchases. When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network. Thanks for your support!

  • Back to top