The Python 🐍 problem-solving bootcamp πŸš€ is starting soon. Join the second cohort now!

Learn how I used Python in my daily life to convert 5,000 RAW images into the JPEG format.

The Python 🐍 problem-solving bootcamp is starting soon. Join the second cohort now!


I have a folder with 4,902 RAW images and I want to convert them into the format JPEG to make it easier to share them with friends and family.

I wasn't sure how I would convert almost 5,000 RAW images into another format but Python had my back. A quick Google search brought up a similar Stack Overflow question from someone trying to do something similar.

I installed the modules rawpy and imageio with python -m pip install rawpy imageio and it took me a couple of lines of code to convert my first image.

I added a loop to go over all the images, I added a Rich progress bar to see my code working, and I was done.

Here is a screenshot of the code showing the progress bar, so I know it is still doing work:

Screenshot of a Python script that used a rich progress bar while converting RAW images into JPEGs.
The progress bar during the execution of the script.

The full code for this script can be found below. Now, I wonder... How much time would I have spent if I did not know Python?!

Convert NEF images into JPG.

Credit to and

import pathlib

import imageio
import rawpy
from rich.progress import track

FROM = pathlib.Path(...)  # Folder to read from.
TO = pathlib.Path(...)  # Folder to save images into.

images = list(FROM.glob("*"))

for img in track(images):
    with rawpy.imread(str(img)) as raw:
        rgb = raw.postprocess(rawpy.Params(use_camera_wb=True))
    new_location = (TO /".jpg")
    imageio.imsave(new_location, rgb)

Take your Python 🐍 skills to the next level πŸš€

I write about Python every week. Join +16.000 others who are taking their Python 🐍 skills to the next level πŸš€, one email at a time.

Previous Post Next Post

Blog Comments powered by Disqus.