From: Steinar H. Gunderson Date: Mon, 23 Jul 2007 09:23:05 +0000 (+0200) Subject: Do dcraw delegation stuff ourselves, which should hopefully finally fix the X-Git-Url: https://git.sesse.net/?p=pr0n;a=commitdiff_plain;h=6a46b55c9390d00d5aef5c7720622a35d48b187e;ds=sidebyside Do dcraw delegation stuff ourselves, which should hopefully finally fix the NEF-and-threading bugs. --- diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 6fb5536..d7a081d 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -314,11 +314,23 @@ sub ensure_cached { # Need to generate the cache; read in the image my $magick = new Image::Magick; my $info = Image::ExifTool::ImageInfo($fname); - - # NEF files aren't autodetected - $fname = "NEF:$fname" if ($filename =~ /\.nef$/i); + 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); + } - my $err = $magick->Read($fname); if ($err) { $r->log->warn("$fname: $err"); $err =~ /(\d+)/;