Why is ufraw-batch used by default on linux?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Karolis
Posts: 3
Joined: 2013-01-14T09:51:01-07:00
Authentication code: 6789

Why is ufraw-batch used by default on linux?

Post by Karolis »

From my subjective experience dcraw does a much better job converting CR2 files on linux than ufraw-batch. That is with least manual tweaking.

Why is ufraw-batch used in linux by default even though dcraw is available on all platforms?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Why is ufraw-batch used by default on linux?

Post by magick »

ufraw-batch is available on some of the newer Linux system, no manual install of dcraw is required. You can of course edit delegates.xml on your system and change it from ufraw-batch to dcraw.
Karolis
Posts: 3
Joined: 2013-01-14T09:51:01-07:00
Authentication code: 6789

Re: Why is ufraw-batch used by default on linux?

Post by Karolis »

magick wrote:ufraw-batch is available on some of the newer Linux system, not manual install of dcraw is required. You can of course edit delegates.xml on your system and change it from ufraw-batch to dcraw.
That's what I'm currently doing, but it's a bit annoying. At least I know why. Thanks for a prompt reply.
electricart
Posts: 14
Joined: 2013-07-23T17:53:31-07:00
Authentication code: 6789

Re: Why is ufraw-batch used by default on linux?

Post by electricart »

Hi there,

Sorry to bring up an older thread, but I was wondering if you could please post your working section from delegates.xml for dcraw for Linux? I can't get anything I've tried to work. The older examples that are floating around in the documentation don't seem to work with newer versions, and some of the entries that I've tried have resulted in the original file being deleted! Any help for a working entry for dcraw would be greatly, greatly appreciated, as we are having major problems with ufraw-batch and Canon (CR2) files (mainly pink highlights and strange clipping - even when clipping is turned off in ufraw-batch). Dcraw works fine for us.

We've tried many of the options suggested in this thread;

viewtopic.php?f=1&t=15605&start=0

However we still can't get it to work. If anyone has a working example, could you please kindly post it?

Thanks so much.
Karolis
Posts: 3
Joined: 2013-01-14T09:51:01-07:00
Authentication code: 6789

Re: Why is ufraw-batch used by default on linux?

Post by Karolis »

This is what I've settled on:

Code: Select all

<delegate decode="dng:decode" stealth="True" command="dcraw -6 -W -O "%u.ppm" "%i""/>
Seems to be working just fine.
electricart
Posts: 14
Joined: 2013-07-23T17:53:31-07:00
Authentication code: 6789

Re: Why is ufraw-batch used by default on linux?

Post by electricart »

Thanks so much for the reply.

Unfortunately that doesn't work for us. We get the "unknown -O option" error message as mentioned in the other thread due to the removal of the '-O' option from Dcraw.

viewtopic.php?f=1&t=15605&start=0

What version of Dcraw did you build and how did you build it?

I tried the version from the Imagemagick server under delegates, but still had this problem. Do I need to recompile ImageMagick as well as Dcraw to make this work?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Why is ufraw-batch used by default on linux?

Post by fmw42 »

My understanding is that IM must be re-installed (at least on unix) when you update a delegate. I would not use the delegates from the IM directory. They may be outdated. I would search the web for the supplier of the delegate and use their latest version.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why is ufraw-batch used by default on linux?

Post by snibgo »

The dcraw situation is slightly different, I think.

The standard program (http://www.cybercom.net/~dcoffin/dcraw/dcraw.c ) doesn't contain the "-O" option to send output to a file. For IM, the standard program is patched to include this option.

For the windows IM distribution, dcraw.exe is included. The version number (currently v9.19) is generally the same as on Dave Coffin's site.
snibgo's IM pages: im.snibgo.com
electricart
Posts: 14
Joined: 2013-07-23T17:53:31-07:00
Authentication code: 6789

Re: Why is ufraw-batch used by default on linux?

Post by electricart »

Hi. Thanks so much for the replies.
My understanding is that IM must be re-installed (at least on unix) when you update a delegate. I would not use the delegates from the IM directory. They may be outdated. I would search the web for the supplier of the delegate and use their latest version.
I did end up re-installing ImageMagick after building the IM delegate Dcraw (v9.04). I was hoping it would be the patched version that includes the -O option, however it appears not as I still have the same issue. Downloading the latest Dcraw (v9.19) from Dave Coffin's site is what I did initially, however this does not work either due to the missing -O option.

As snibgo said;
The standard program (http://www.cybercom.net/~dcoffin/dcraw/dcraw.c ) doesn't contain the "-O" option to send output to a file. For IM, the standard program is patched to include this option.

For the windows IM distribution, dcraw.exe is included. The version number (currently v9.19) is generally the same as on Dave Coffin's site.
Does that mean that the windows IM distribution of dcraw.exe includes the patch for -O? Unfortunately it doesn't help us as we are on Linux, and the Dcraw on the ImageMagick site does not appear to be patched.

What is frustrating is that we used to use the following in our delegates.xml with a previous version of ImageMagick (but the latest Dcraw) and it worked fine;

Code: Select all

<delegate decode="dcraw" command='"dcraw" -c -w "%i" > "%o"' />
However now the same entry updated with "dng:decode" now deletes the file it tries to convert (!) as well as failing the conversion. Bad news!

Code: Select all

<delegate decode="dng:decode" command='"dcraw" -c -w "%i" > "%o"' />
Is there any way that anyone knows to use a recent dcraw version on Linux with recent builds on ImageMagick?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why is ufraw-batch used by default on linux?

Post by snibgo »

electricart wrote:Does that mean that the windows IM distribution of dcraw.exe includes the patch for -O?
Yes. dcraw.exe is the compiled binary.

Some while ago (30 March 2013), I downloaded the source for IM v7, which includes dcraw v9.16. Here is the diff file:

Code: Select all

diff -r a9fccc1b01d0 dcraw/dcraw.c
--- a/dcraw/dcraw.c	Sun Sep 30 17:46:00 2012 -0500
+++ b/dcraw/dcraw.c	Sun Oct 07 15:13:04 2012 -0500
@@ -28,6 +28,8 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRALEAN
 #define _USE_MATH_DEFINES
 #include <ctype.h>
 #include <errno.h>
@@ -42,6 +44,10 @@
 #include <time.h>
 #include <sys/types.h>
 
+#if !defined(M_PI)
+#  define M_PI 3.14159265358979323846
+#endif
+
 #ifdef NODEPS
 #define NO_JASPER
 #define NO_JPEG
@@ -63,7 +69,7 @@
 #define _(String) (String)
 #endif
 
-#if defined(DJGPP) || defined(__MINGW32__)
+#if defined(DJGPP) || defined(__MINGW32__) || defined(WIN32) || defined(WIN64)
 #define fseeko fseek
 #define ftello ftell
 #else
@@ -113,6 +119,7 @@
 FILE *ifp, *ofp;
 short order;
 const char *ifname;
+char *outfile = NULL;
 char *meta_data;
 char cdesc[5], desc[512], make[64], model[64], model2[64], artist[64];
 float flash_used, canon_ev, iso_speed, shutter, aperture, focal_len;
@@ -9113,6 +9120,7 @@
     puts(_("-r <r g b g> Set custom white balance"));
     puts(_("+M/-M     Use/don't use an embedded color matrix"));
     puts(_("-C <r b>  Correct chromatic aberration"));
+    puts(_("-O <file> Write output to this file"));
     puts(_("-P <file> Fix the dead pixels listed in this file"));
     puts(_("-K <file> Subtract dark frame (16-bit raw PGM)"));
     puts(_("-k <num>  Set the darkness level"));
@@ -9181,6 +9189,7 @@
 #endif
 	break;
       case 'P':  bpfile     = argv[arg++];  break;
+      case 'O':  outfile    = argv[arg++];  break;
       case 'K':  dark_frame = argv[arg++];  break;
       case 'z':  timestamp_only    = 1;  break;
       case 'e':  thumbnail_only    = 1;  break;
@@ -9444,7 +9453,10 @@
     if (write_to_stdout)
       strcpy (ofname,_("standard output"));
     else {
-      strcpy (ofname, ifname);
+      if (outfile)
+        strcpy (ofname,outfile);
+      else {
+        strcpy (ofname, ifname);
       if ((cp = strrchr (ofname, '.'))) *cp = 0;
       if (multi_out)
 	sprintf (ofname+strlen(ofname), "_%0*d",
@@ -9452,6 +9464,7 @@
       if (thumbnail_only)
 	strcat (ofname, ".thumb");
       strcat (ofname, write_ext);
+      }
       ofp = fopen (ofname, "wb");
       if (!ofp) {
 	status = 1;

As you can see, the changes for "-O" are fairly minimal. This diff file may not be accurate for current dcraw, v9.19. You should probably ignore changes that refer to WIN32 etc.
snibgo's IM pages: im.snibgo.com
electricart
Posts: 14
Joined: 2013-07-23T17:53:31-07:00
Authentication code: 6789

Re: Why is ufraw-batch used by default on linux?

Post by electricart »

Thanks so much for the reply and the patch - that's exactly what I needed! Very much appreciated. I was able to successfully apply the patch and build Dcraw however I have a strange issue. When I call convert from the command line, it works;

Code: Select all

'/usr/bin/convert' '/media/Sparkler/MG_4988.CR2'[0] +matte -quality 90 -intent relative -black-point-compensation -colorspace sRGB -profile 'media/iccprofiles/sRGB_IEC61966-2-1_black_scaled.icc' -resize 999999x999999">" '/media/filestore/79486hpr_fddca8be4da363c.jpg'
However, when exactly the same command is called from php, I get the same error as before;

Code: Select all

Unknown option "-O".
It's driving me a little mad. Php is calling the correct version of convert as it is explicitly being called - at /usr/bin/convert' - so I can't work out what's happening. Any ideas?

Thanks again for all your help.
electricart
Posts: 14
Joined: 2013-07-23T17:53:31-07:00
Authentication code: 6789

Re: Why is ufraw-batch used by default on linux?

Post by electricart »

I worked it out.

I needed to define the full path in delegates.xml.

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why is ufraw-batch used by default on linux?

Post by snibgo »

I don't know PHP, but I suppose it has a version of "path" -- a list of directories that are searched for executables. This list may be different to the one from the command line.

Another way of looking at it: you must have at least 2 versions of compiled dcraw.

You might try putting the full path to dcraw in delegates.xml.

EDIT: Cross-posted! Glad it now works. For future upgrades, you might want to remove old versions of dcraw, and put the new version where convert running under PHP expects to find it.
snibgo's IM pages: im.snibgo.com
Post Reply