I shoot with a Nikon in RAW, which creates Nikon's NEF files. I wanted to rate these (from 1-5). Currently I use ApolloOne on macOS (due to its performance and ability to view both JPEG and RAW files quickly). However, when I use its rating feature, it seems to create auxiliary .XMP files. I would rather have the rating contained within the metadata of the .NEF file itself, but have not found a way to do so.

I also realize that I can rate photos in Lightroom (and even rate it with other properties, such as flags or colors), but again these are stored in the Lightroom catalog rather than in the original file itself.


There are tools like Exiv2 that in principle allow you to read from and write to the metadata in image files, even in raw files like .NEF files. But you'll have to figure out which tags to write to, and to my knowledge, EXIF only allows ASCII characters (7-bit).

Do note that some consider writing to raw files as bad practice. Raw file formats are usually not well described. This means that it's easy to make an error that makes the raw file unreadable. And the raw file is more or less your base data (like the negative in the film days). That is also the reason those sidecar .XMP files are created by most programs that modify the metadata.

An exception to this is the DNG format, as long as it's not your camera's native format: while this is technically a raw format (in most cases, there is also something called lossy DNG...), the DNG format is well described. Also, .DNG files are usually created from another raw format, and as such are not the original data. (again, unless the camera creates the .DNG, which is an option with certain Pentax models).

| improve this answer | |
  • 1
    The last time I was working with extracting data from NEF files, they were in reality TIFF files containing a mix of proprietary and publicly documented (e.g. EXIF) data segments. Has that changed in later versions of the NEF file format? If not, there is no reason not to be able to edit the well-known segments of the file and leave the proprietary data untouched and your warning is moot. – jarnbjo Apr 10 '18 at 14:17
  • No idea if all NEF files are the same format, and that's the problem... And there are a lot of other raw formats out there as well... But of course, everyone is free to do what he wants with his data, the advice not to write to raw files is just that, advice. – remco Apr 10 '18 at 14:52
  • Thanks for the explanation. In general, does this mean that rating RAW files is not recommended overall? How does one manage photos, then? Does one need to use a piece of photo managing software, such as Lightroom? – Skeleton Bow Apr 10 '18 at 17:04
  • Most programs I know of that manage photos and let you set tags and ratings use a database and (possibly optional) sidecar files. Normally, the program takes care of the sidecar files transparantly, but they can be a problem when you have to interfere outside the management program. Anyway, how would you use the ratings other than through a management program? – remco Apr 10 '18 at 17:15
  • I would say it is more the case that back when file fragmentation was more of an issue with the file systems certain OSs used it was standard advice to never write to an original raw file. Now it's just a case of always doing things the way we've always done them without stopping to think about why we do them that way. – Michael C Apr 12 '18 at 3:05

It's not Nikon, but Canon's Digital Photo Professional writes all changes in EXIF metadata directly to the raw file. DPP does not even offer the option of using external sidecar files to hold editing data. It is always included in the maker notes section of the metadata within the main file. There is no external catalogue to fall back on. There is only the data contained in the image file.

This includes "star" ratings of 1-5 stars. Other raw processing applications, such as ACR, CaptureOne, etc. can read these star ratings if the raw file is copied to another machine and later opened in those other applications.

The above would seem to indicate that writing such data directly to the file is not only possible, but practical and relatively risk free.

I've never experienced a corrupted .cr2 file that wasn't my fault for doing something such as accidentally deleting a fragmented file and overwriting part of the medium that contained the file before attempting to recover the deleted file or some other kind of ID10T error.

To be more specific, I currently have archived in triplicate upwards of 250,000 .cr2 files processed only with various versions of Canon's DPP. Not a single XMP sidecar file exists anywhere for any of those .cr2 files. I have yet to encounter a single instance of an unexplained corrupted .cr2 file out of those 750,000 plus examples.

If anyone is experiencing issues with corrupted files as a result of not using discrete XMP sidecar files to save changes to the metadata of raw image files, I would suggest the issue might be with the application one is using, or perhaps with the file system one's OS is using, and not due to the act of writing metadata changes directly to the raw file.

Canon also has a "checkmark" system, totally distinct from the "star" rating system, that is, as far as I know, only recognized by Canon's in various house software applications.

| improve this answer | |
  • Quite possible that writing to raw files is in practice very safe. However, the question was how to write to Nikon NEF files, and I replied to that with a disclaimer about what some consider best practice. Seems that the latter is the only part people read :/ – remco Apr 12 '18 at 4:51
  • I'm not sure what part of your answer you feel I didn't read. Could you elaborate? Also, just because some people consider something a best practice does not make it so. And honestly, it seems more like your answer is advocating that position as essentially correct, rather than presenting it as one of several positions. – Michael C Apr 12 '18 at 5:06
  • Ignored: the actual answer to the question. But ok, I toned down the bit about writing to raw. But even if the loss on writing to raw is due to operator error, you still lose that file... – remco Apr 12 '18 at 5:44
  • @remco Saying "There are tools... that in principle allow..." one to do something strongly implies that it is not actually practical. "But even if the loss on writing to raw is due to operator error, you still lose that file" That's what backups are for. – Michael C Apr 12 '18 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.