Discussion:
Batch Processing with DCRaw plugin
Aaron Hendrickson
2013-01-24 16:12:39 UTC
Permalink
Hello,

I have over 700 raw nikon images (.NEF) that I want to open with the DCRaw
plugin and save as 16-bit tiffs. In addition, all the options that are set
in the DCRaw plugin before it opens a raw image must be the same for all
700+ .NEF files I have. I tried recording a macro to automate this process
with no success. How might I automate this task for each image without
doing it all by hand?

Thanks in advance,
Aaron Hendrickson.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Rainer M. Engel
2013-01-24 20:25:07 UTC
Permalink
From what I read on the plugin's website
http://ij-plugins.sourceforge.net/plugins/dcraw/

it depends on the executable and is listed under Plugins/Image IO in the
menu after installation.

I don't use or know it, but you could start by trying your recorded
macro lines for one of these raw files in the macro template below.


Plugins>New>Macro (or shortcut) and then paste these lines..
---------------------------------------------------------------

dir1 = getDirectory("Open RAW images..");
list1 = getFileList(dir1);

for (i=0; i<list1.length; i++) {
showProgress(i+1, list1.length);
print("image-name: "+list1[i]);

//+++++++++++++++++++++++++++++++++++++++++++++++
//place your commands of opening and saving here,
//note to use the variable to open consecutive
//frames.
//+++++++++++++++++++++++++++++++++++++++++++++++

}

---------------------------------------------------------------

Hope this provides some help.

Best Regards,
Rainer
Hello,
I have over 700 raw nikon images (.NEF) that I want to open with the DCRaw
plugin and save as 16-bit tiffs. In addition, all the options that are set
in the DCRaw plugin before it opens a raw image must be the same for all
700+ .NEF files I have. I tried recording a macro to automate this process
with no success. How might I automate this task for each image without
doing it all by hand?
Thanks in advance,
Aaron Hendrickson.
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Aaron Hendrickson
2013-01-25 13:50:14 UTC
Permalink
Thank you for your replies Wayne and Rainer. I should have been more
specific in regards to the issues I had with the recorder. I was able to
create a macro with the recorder that worked, however, I had to change the
file name in the macro for every file I wanted to open. Here is the macro
I recorded:

run("DCRaw Reader...", "open=[C:\\Users\\Owner\\Desktop\\RAW
Files\\DSC_2143.NEF] open=[C:\\Users\\Owner\\Desktop\\RAW
Files\\DSC_2143.NEF] use_temporary_directory white=None don't
output_colorspace=[0 - raw] document_mode document_mode_without_scaling
read=[16-bit linear] interpolation=[0 - High-speed, low-quality bilinear]
do");
saveAs("Tiff", "C:\\Users\\Owner\\Desktop\\TIFF Files\\DSC_2143.tif");
close();

My question is how do I run this macro to perform this process for all of
my images (702 in total)? Rainer supplied me with a template to use but I
have such little experience with programming that I do not know how to use
it.

Thank you,
Aaron Hendrickson.
From what I read on the plugin's website
http://ij-plugins.sourceforge.net/plugins/dcraw/
it depends on the executable and is listed under Plugins/Image IO in the
menu after installation.
I don't use or know it, but you could start by trying your recorded
macro lines for one of these raw files in the macro template below.
Plugins>New>Macro (or shortcut) and then paste these lines..
---------------------------------------------------------------
dir1 = getDirectory("Open RAW images..");
list1 = getFileList(dir1);
for (i=0; i<list1.length; i++) {
showProgress(i+1, list1.length);
print("image-name: "+list1[i]);
//+++++++++++++++++++++++++++++++++++++++++++++++
//place your commands of opening and saving here,
//note to use the variable to open consecutive
//frames.
//+++++++++++++++++++++++++++++++++++++++++++++++
}
---------------------------------------------------------------
Hope this provides some help.
Best Regards,
Rainer
Post by Aaron Hendrickson
Hello,
I have over 700 raw nikon images (.NEF) that I want to open with the
DCRaw
Post by Aaron Hendrickson
plugin and save as 16-bit tiffs. In addition, all the options that are
set
Post by Aaron Hendrickson
in the DCRaw plugin before it opens a raw image must be the same for all
700+ .NEF files I have. I tried recording a macro to automate this
process
Post by Aaron Hendrickson
with no success. How might I automate this task for each image without
doing it all by hand?
Thanks in advance,
Aaron Hendrickson.
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Jarek Sacha
2013-01-25 20:39:49 UTC
Permalink
Aaron,

Below is a basic macro that batch converts using dcraw plugin. Currently
there are some problems using some of the options from an ImageJ macro.
Though it should work using alternative scripting engine like Groovy,
Scala, possibly JavaScript or other. Let me know I can prepare a sample
for one of those. I will try to fix macro issue in a future release of
dcraw plugin.

Jarek

//------------------------------------------------------------------------------------------------------------
//Get File Directory and file names
dirSrc = getDirectory("Select Input Directory");
dirDest = getDirectory("Select Output Directory");
fileList = getFileList(dirSrc);
caption = "dcraw batch converter";

print(caption + " - Starting");
print("Reading from : " + dirSrc);
print("Writing to : " + dirDest);

// Create output directory
File.makeDirectory(dirDest);

setBatchMode(true);
fileNumber = 0;
while (fileNumber < fileList.length) {
id = fileList[fileNumber++];

print(toString(fileNumber) + "/" + toString(fileList.length) + ": "
+ id);

// Read input image
run("DCRaw Reader...",
"open="+dirSrc + id+" "+
"use_temporary_directory " +
"white=None " +
"output_colorspace=[0 - raw] " +
"read=[16-bit linear] " +
"interpolation=[0 - High-speed, low-quality bilinear]");
idSrc = getImageID();

// Save result
saveAs("Tiff", dirDest + id);

// Cleanup
if (isOpen(idSrc)) {
selectImage(idSrc);
close();
}
}
print(caption + " - Completed");
//------------------------------------------------------------------------------------------------------------

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Jarek Sacha
2013-01-27 04:09:51 UTC
Permalink
Just released new version of ij-dcraw:
https://sourceforge.net/projects/ij-plugins/files/ij-dcraw/v.1.4.0/

It adds full support for using from ImageJ macros. You can see a simple
batch processing macro on its home page:
http://ij-plugins.sourceforge.net/plugins/dcraw/index.html

Jarek

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Rainer M. Engel
2013-01-30 16:40:32 UTC
Permalink
Post by Jarek Sacha
https://sourceforge.net/projects/ij-plugins/files/ij-dcraw/v.1.4.0/
I wrote a macro for batch purposes, which was evaluated with support of
Aaron Hendrickson and is of course provided as is.

Feel free to use it (DCRaw_ConvertToTif_v04.ijm):
https://dl.dropbox.com/u/414433/imagej/DCRaw_ConvertToTif_v04.ijm

Regards,
Rainer
--
Rainer M. Engel, Dipl. Digital Artist
scientific|Media GbR
Pichelsdorfer Str. 143
13595 Berlin

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Loading...