How to convert CR2 to JPG or PNG?

I'll go a different route... Use ufraw-batch not ufraw.

sudo apt-get install ufraw-batch

## This will output (not replace) the file with a new extension.
## foo.CR2 exported to foo.png
ufraw-batch --out-type png *.CR2

See ufraw-batch --help and man ufraw-batch for more info.


Ufraw

you can convert .cr2 to .jpeg by ufraw.

sudo apt-get install ufraw

Right click on the file and select open with ufraw.

** You can also import them to Gimp with gimp-ufraw and then export as .png or .jpeg.

sudo apt-get install gimp-ufraw

ufraw alternatives

The accepted answer recommends to use ufraw, but ufraw's development has ceased as of June 2015 and it's not supported by current Ubuntu releases. See Ubuntu Bugtracker, which recommends darktable or rawtherapee as alternatives. Both tools are GU tools, but it is possible to use them from CLI.

darktable: manual, man page

Batch processing example:

for pic in *.CR2
do
     darktable-cli "$pic" "$(basename ${pic%.CR2}.jpg)"; 
done

rawtherapee: manual