2

I'm converting about 9000 photos from .NEF to .jpg.

  • I'd like to retain all EXIF data, most importantly Date and time created, Latidude and Longitude.
  • I'd like the JPGs to be at the highest possible quality.

I've just gotten started using ImageMagick from the command line. I also have Exiftool installed. I'm using the mogrify command because it handles batches nicely.

When I run

mogrify -format jpg *.NEF

All of my .NEF files are successfully converted to JPGs, but all EXIF data are lost.

I've searched around quite a bit to try and find a solution to this and it seems like I may have to install ufraw, but if possible I'd like a solution that uses software I already have - ImageMagick and Exiftool.

Thanks in advance for any advice you have about how to do this.

Update:

  • The images I converted using mogrify are slightly smaller (~ 1-2 MB) than those output by my colleague using picasa to convert NEF to JPG. But when I specify -quality 100 in ImageMagick the image sizes gain about 45 MB! Why?
  • The code exiftool -tagsfromfile %d%f.NEF -ext jpg -overwrite_original . adds the exif information to the JPGs.
Nova
  • 5,423
  • 2
  • 42
  • 62

1 Answers1

5

Think twice before doing this - you really are discarding a lot of information - and if you don't want it, why not shoot JPEG instead of RAW in the first place?

FWIW, you can use ImageMagick to get the JPEG:

convert somefile.NEF somefile.jpg

Then you can copy the tags across from the original to the file newly created by ImageMagick:

exiftool -tagsfromfile somefile.NEF -all:all somefile.jpg 

If you have thousands of images, and are on macOS or a decent Linux/Unix-based OS, I would recommend GNU Parallel like this and it will keep busy all those lovely cores that you paid Intel so dearly for:

parallel --dry-run 'convert {} {.}.jpg; exiftool -tagsfromfile {} -all:all {.}.jpg' ::: *nef

Sample Output

convert a.nef a.jpg; exiftool -tagsfromfile a.nef -all:all a.jpg
convert b.nef b.jpg; exiftool -tagsfromfile b.nef -all:all b.jpg

and if that looks good remove the --dry-run so it actually runs the command.


If you are on Windows, you will have to do some ad-hoc jiggery-pokery to get it done in any reasonable time frame. You can use the mogrify command and get all the conversions done to JPEG and then do all the exiftool re-embedding of the EXIF data later. If your files are named with some sort of system with incrementing numbers, you can start two or three copies of mogrify in parallel - say one doing files whose names end in [0-4] and another one doing files whose names end in [5-9]. I don't speak Windows, but that would probably look like these two commands each running in its own Command Prompt:

mogrify -format jpg *0.NEF *1.NEF *2.NEF *3.NEF *4.NEF

mogrify -format jpg *5.NEF *6.NEF *7.NEF *8.NEF *9.NEF

Then you would do the exiftool stuff when they had all finished but you would have to use a FOR loop like this:

FOR %%G IN (*.NEF) DO (
   exiftool -tagsfromfile %%G -all:all %%~dpnG.jpg
)

The %%~dpnG part is a guess based on this answer.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Thanks Mark, appreciate it. Your example looks like it's for one photo - how would I batch this for 9000? Just an explanatory note: we take the photos in RAW to have the maximum amount of information in case we need them later. We are putting all photos into a mosaic, and our mosaic program doesn't take NEFs - the jpgs have worked fine in the past. I'm part of a larger research team, and I don't have control over what format the photos are taken in ;) – Nova Nov 15 '17 at 15:43
  • What OS are you using? – Mark Setchell Nov 15 '17 at 15:48
  • Using Windows 7. I do have 40 gigs of RAM but I'd like to be able to save maybe 4 gigs for other work today? I can always let it run overnight. – Nova Nov 15 '17 at 15:53
  • Thanks for the update, @Mark Setchell! But I'm looking for a Windows solution... it sounds like that code won't run on my Windows computer? – Nova Nov 15 '17 at 16:02
  • Great! Thanks for that tip for processing mogrify in parallel. I've updated my question as well to a solution that doesn't create annoying backup jpgs. – Nova Nov 15 '17 at 16:10