+ my $err;
+
+ # ImageMagick can handle NEF files, but it does it by calling dcraw as a delegate.
+ # The delegate support is rather broken and causes very odd stuff to happen when
+ # more than one thread does this at the same time. Thus, we simply do it ourselves.
+ if ($filename =~ /\.nef$/) {
+ # this would suffice if ImageMagick gets to fix their handling
+ # $fname = "NEF:$fname";
+
+ open DCRAW, "-|", "dcraw", "-w", "-c", $fname
+ or error("dcraw: $!");
+ $err = $magick->Read(file => \*DCRAW);
+ close(DCRAW);
+ } else {
+ $err = $magick->Read($fname);
+ }