How to Convert Raw Camera Images (cr3, crw) to jpg in Ubuntu

Having a raw image? Want to know how to convert a cr2, cr3, or crw format image to jpg, then you can use dcraw, rawtherapee, or darktable.

Today I found my old memory card, on which I saved a number of photos that I clicked from my DSLR, and while viewing the photos, I found some old photos with my friends.

I thought I should share some photographs with him so he can also relive those memories with me and we can catch up on old times.

So, I immediately sent him photos, and he replied to me back that I’m not able to view photos; also, the image format is .crw, and he asked me to send photos in jpg or jpeg format.

Alright, give me five minutes, and I’ll send those images in jpg format.

He is waiting for me to send photos, but you can continue right along with the steps to convert raw images to jpg or jpeg.

Steps to Convert Raw Images to JPEG/JPG

For this particular task, there are several tools available in the Linux environment, from ImageMagick to Rawtherapee, dcraw, Darktables, and so on.

However, ImageMagick methods were working on the earlier build of Ubuntu, but on the latest build, you will find the following error: delegate failed `’ufraw-batch’ –silent –create-id=also –out-type=png –out-depth=16 ‘–output=%u.png’ ‘%i” @ error/delegate.c/InvokeDelegate/1924.

Therefore, we are skipping the ImageMagick method and covering the following methods to convert a raw image to jpeg or jpg format:

  • dcraw command to convert raw image
  • rawtherapee-cli command to convert raw image
  • Darktable to convert the raw image

dcraw command to convert raw image

The dcraw is the underlying tool that is used in most of the programme to handle raw images, and we will also use the same dcraw command to convert raw images into jpg format.

And one of the prime reasons to go with the dcraw command is that you don’t need to download or perform any activity before getting started with conversion.

But due to some reason, if the dcraw is not available, then execute the following command to install it on your Linux machine:

$ sudo apt install dcraw
$ sudo dnf install dcraw

Once you have installed dcraw, change your current directory to where the raw file is located and pass the following syntax to convert the raw image into a jpg.

$ dcraw -c -w input_raw_image.ext | cjpeg > output.jpg
  • -c: Put the processed image on standard output
  • -w: If the white balance value is available from the camera, then it will be adopted, or else it will throw an error
  • |: pipe the processed image to the cjpeg command to compress it and save the result

Once the conversion is done, you can use the file command to check the conversion result, like shown in the below image:

Result after conversion
Result after conversion

Not only that, you can also specify the quality of jpeg/jpg by using the -quality flag, as shown below:

$ dcraw -c -w input_raw_image.ext | cjpeg -quality 90 > output.jpg

The above command will not be useful enough to batch convert all the raw images that are available in a particular directory.

Then you can take advantage of the “for loop” to iterate and convert all the raw images to jpg.

As you can see in the below image, it will convert all the raw images that end with a .crw extension in the current directory and save the output with the same file name but the extension will be a .jpg.

$  for FILE in *.crw; do dcraw -c -w "$FILE" | cjpeg -quality 90 -outfile "${FILE%.*}.jpg"; done ; echo "CONVERSION COMPLETE ☻"

The output of the above command is shown below.

Convert all the raw images from directory
Convert all the raw images from the directory

rawtherapee-cli command to convert raw image

Alternatively, you can use the RawTherapee tool to convert raw images to jpg format, which is also one of the best options for converting images.

As a matter of fact, Rawtherapee will not be available out of the box, so execute the following command to install the rawtherapee-cli and its GUI tool:

$ sudo apt install rawtherapee

Once you are done with the installation of the command, you can execute the following command to convert the raw image to jpg, which looks more simple than the above command no piping, no redirection and easy to remember.

$ rawtherapee-cli -c -Y input_raw_image.ext 
  • -c: Accept one or more files
  • -Y: Will overwrite if the output is already present in the directory.
  • input_raw_image.ext: Replace with the file path

For instance, if you want to specify jpg file quality, then use the -j flag with a value on a scale of 1 to 100.

$ rawtherapee-cli -j80 -c sample_1.crw

As I said, the -c flag accepts more than one input, so you don’t need to loop out the command to convert all the images to jpg.

Then let me show you how to convert all the .crw files to jpg by using the following syntax:

$ rawtherapee-cli -j80 -c *.crw

If you want, you can also use the Rawtherappe GUI application for making changes like tweaking the contrast brightness and many more.

darktable-cli command to convert raw image

Another great option we have is Darktable which also use the dcraw under the hood for processing raw images. To install Darktable you need to run the following command, then we will use the darktable-cli command as a cr3 to jpg converter.

$ sudo apt install darktable

Once you have installed Darktable, run the following command, by replacing /input/path/raw_image.ext and /output/path/ with the actual files.

$ darktable-cli /input/path/raw_image.ext  /output/path/ --out-ext ".jpg"

If you want to make batch operations, then you can use the loop operation to convert all the raw files, which end with *.crw to jpg.

$ for FILE in /input-path/*.crw; do darktable-cli "$FILE" "${FILE%.*}.jpg"; done

Don’t you think it’s pretty simple to convert a raw image to jpg?

Wrap up

That’s all for this article, where you learn how to convert raw images to jpg format for sharing with friends and family.

We have used the following command as a cr3 to jpg converter in Linux:

  • Dcraw:
    • $ dcraw -c -w input_raw_image.ext | cjpeg > output.jpg
  • RawTherapee:
    • $ rawtherapee-cli -c -Y input_raw_image.ext
  • Darktable:
    • $ darktable-cli /input/path/raw_image.ext /output/path/ --out-ext ".jpg"

If you like this article, then do leave a comment.

Leave a Reply