Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How do you convert canon raw files to TIFF?


    A piece of software that i am using can only import TIFF files. I would like to convert around 100 RAW Canon image files (.cr2) to TIFF. I can't find any way of doing it, other than opening each one in GIMP, and saving it as a TIFF. If there is a faster way, I would like to know about it.

  2. #2
    Linux User
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    312
    Check out "ufraw" for a CLI option. You can script it to convert a bunch of files.

    Here are two scripts I used to use that converts a directory of NEF (Nikon raw) files to 165 bit PNG's. I switched to using RawTherapee for initially screnning my raw photos so I don't convert them to PNG's in bulk anymore.

    One scripts finds all the files and the other converts a single file using "ufraw". You could tweak the conversion script to look for CR2 files and output TIFF's instead.

    Here's the driver script. It's more complicated that it needs to be, since I wanted the conversions to go as fast as possible. So it's running multiple conversions in parallel as background scripts. I have a 8-core CPU so it does 8 conversions at once.

    Code:
    #!/bin/bash
    
    CONVERT="nef2png"
    
    def_max_procs=8
    
    # ---
    
    if [ "${MAX_PROCS}" = "" ]
    then
    	nlists=${def_max_procs}
    else
    	nlists=${MAX_PROCS} + 0
    fi
    
    if [ ${nlists} -lt 1 -o ${nlists} -gt 8 ]
    then
    	nlists=${def_max_procs}
    fi
    
    # ---
    
    nn=1
    wh=1
    
    for fn in $*
    do
    #	echo "-- ${nn} ${wh} ${fn} -- ${filelist[${wh}]}"
    
    	filelist[${wh}]="${filelist[${wh}]} $fn"
    
    # ---
    
    	nn=$(( ${nn} + 1 ))
    
    	wh=$(( ${wh} + 1 ))
    
    	if [ ${wh} -gt ${nlists} ]
    	then
    		wh=1
    	fi
    done
    
    # ---
    
    wh=1
    
    while [ ${wh} -le ${nlists} ]
    do
    #	echo ""
    	echo "${wh}. ${filelist[${wh}]}"
    
    	wh=$(( ${wh} + 1 ))
    done
    
    # ---
    
    wh=1
    
    while [ ${wh} -le ${nlists} ]
    do
    #	echo ""
    #	echo "-- ${wh}"
    #	echo "${filelist[${wh}]}"
    
    	(
    		for fn in ${filelist[${wh}]}
    		do
    			echo "--> ${wh}. ${fn}"
    			${CONVERT} "${fn}"
    		done
    	) &
    
    	wh=$(( ${wh} + 1 ))
    done
    
    # ---
    
    wait
    
    # ---
    
    exit 0
    And here's the one that does the conversion. This one needs to be called "nef2png" unless you change the name of the script in the driver.
    Code:
    #!/bin/bash
    
    if [ ! -f "$1" ]
    then
    	echo "**Error** File '$1' doesn't exist or isn't a regular file."
    	exit 1
    fi
    
    # ---
    
    fdir=$(dirname "$1")
    file=$(basename "$1")
    
    list="$(gawk -v file="${file}" '
    
        BEGIN \
        {
    
    	if( file != "")
    	{
    	    seq = file;
    	    sub( "^dsc_", "", seq);
    	    sub( ".nef$", "", seq);
    	    chk = seq;
    	    gsub( "[0-9]", "", chk);
    	    if( chk == "")
    	    {
    		printf "%s nf%d.png\n", file, seq;
    	    }
    	}
        }' \
    )"
    
    if [ "${list}" != "" ]
    then
        nef_file="$(echo "${list}" | gawk '{ print $1; exit 0; }')"
        png_file="$(echo "${list}" | gawk '{ print $2; exit 0; }')"
    fi
    
    #echo "fr(${nef_file}) to(${png_file})"
    
    # ---
    
    if [ "${nef_file}" = "" -o "${png_file}" = "" ]
    then
    	echo "**Error** Something looks odd about file '$1'."
    	exit 1
    fi
    
    # ---
    
    orig="${fdir}/${nef_file}"
    dest="${fdir}/${png_file}"
    
    if [ -f "${dest}" ]
    then
    	echo "-- PNG file '${dest}' already exists."
    #	echo "-- Saving existing file '${dest}'."
    #	mv "${dest}" "${dest}-OLD"
    	exit 0
    fi
    
    # ---
    
    echo "Convert '${fdir}/${nef_file}' to '${fdir}/${png_file}'."
    
    #ufraw-batch --out-type=png8 --output=${dest} ${orig}
    echo "ufraw-batch --wb=camera --out-type=png --out-depth=16 --output=${dest} ${orig}"
    ufraw-batch --wb=camera --out-type=png --out-depth=16 --output=${dest} ${orig}
    
    exit $?

  3. #3
    -->
    I found ufraw and it's exactly what I needed.
    In order to convert all of the .CR2 files to .TIFF, you run this command.
    Code:
    ufraw-batch --out-type=tiff --out-depth=16 *.CR2

$spacer_open
$spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •