I need to convert a lot of CR2 photos to either JPG or PNG, no editing. How to do this?
10 Answers
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.
-
2
-
-
8In some cases, ufraw-batch leads to a segmentation fault. It will successfully develop one RAW file, and then it stops. See bugs.launchpad.net/ubuntu/+source/ufraw/+bug/1768855 for further information. Sep 14, 2018 at 12:13
-
-
1
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.
Batch processing example:
for pic in *.CR2
do
darktable-cli "$pic" "$(basename ${pic%.CR2}.jpg)";
done
rawtherapee: manual
-
This worked for me, unlike
ufraw
,dcraw
andmogrify
, which all outputted very pink images. Oct 6, 2020 at 9:25 -
problem with
darktable-cli
is that your can't run concurrent processes and it's pretty slow. If you're looking to make previews,exiv2 -ep
is an alternative, if the raw files contain embedded jpegs– CervEdAug 5, 2021 at 17:53 -
darktable
did the job as of today, Sept 13, 2021. Sad the many once popular answers are merely the sign of the bygone times of ufraw support.– AdamOSep 13, 2021 at 20:44
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
For another alternative, use mogrify
:
mogrify -format png *.cr2
-
4it should be stated that mogrify is part of imagemagick, which is available at imagemagick.org. however, mogrify uses ufraw-batch in the background, so might as well use that directly Apr 22, 2018 at 9:29
-
4+1 as mogrify circumvents the bug in ufraw-batch that leads to a segmentation fault (asper Sptember 2018)– BruniSep 23, 2018 at 12:30
-
This worked nicely. I just wish there was a verbose option because I didn't realize it was succeeding on a long-running job. Nov 29, 2019 at 2:06
-
6
-
This is now a Famous Question. We do not like these sort of answers. This should be deleted. Aug 2, 2016 at 3:15
-
-
1It's not a helpful answer, but the xnconvert tool worked better for me than all of the other options. You have to download and install the .deb file (no PPA as far as I can tell) but the conversion process was fast and accurate, better colour reproduction than either ufraw or dcraw and faster than either batch process. Using it is reasonably easy, point it at a directory of CR2 files and tell it where to drop the JPEGs and click the button. Aug 26, 2019 at 6:27
The method that really worked for me:
You need dcraw
and ppmtojpeg
(install with apt)
for i in *.CR2; do dcraw -c $i | ppmtojpeg > $1.jpg; echo $i done; done
What it does: First convert CR2 to PPM with dcraw
passing the output to ppmtojpeg
which converts to JPG.
I found this here
-
Since you mentioned apt, it's worth noting that in Debian derivatives,
ppmtojpeg
in included in thenetpbm
package (users may be confused if they search for a package with the same name as the binary).– MarcusAug 10, 2020 at 15:52
Create a bash file like foo.sh and execute as ./foo.sh in command line:
#!/bin/sh
for i in $(ls)
do
ufraw-batch --out-type png $i
echo "conversion done $i"
done
I had trouble with ufraw since it produces a segmentation fault on elementary OS (see https://bugs.launchpad.net/ubuntu/+source/ufraw/+bug/1768855). I combined your answers (thanks!) and finally got a working version.
First get the right command for exiftool (as mentioned by Rafael):
exiftool -s2 -all -b -X -fXMP:XMP test.RAF | grep Preview
which is in my case not -Composite:PreviewImage but:
File:PreviewImage
So you can use the batch script from Abu:
#!/bin/sh
for i in *.RAF
do
exiftool -File:PreviewImage -b $i > $i.jpg
echo $i
done
You could also program a simple loop in the console.
For example (using the fish console), and assuming the active directory only has RAW files.
set files (ls)
for i in $files
dcraw $i
end
or
set files (ls)
for i in $files
ufraw-batch --out-type=tif --out-depth $i
end
I use ufraw-batch that way because it often leads to an error, see https://bugs.launchpad.net/ubuntu/+source/ufraw/+bug/1768855 .
Use:
exiftool -Composite:PreviewImage -b photo.CR2 > photo.jpg
Longer answer:
ufraw-batch conversion quality is very bad. Imagemagick uses ufraw under the hoods (unfortunately). dcraw is better, but still not great. The best solution I found out was to use exif to extract PreviewImage metadata. I believe that's generated by the camera itself.