Dennis O'Keeffe
2 min readSep 27, 2021


Heading image

This is Day 25 of the #100DaysOfPython challenge.

This post will use the OpenCV Python library to apply an oil painting effect to an image.


  1. Familiarity with Pipenv. See here for my post on Pipenv.
  2. An image to use with the OpenCV library.

Getting started

Let’s create the oil-paint-effect-with-open-cv-python directory and install Pillow.

At this stage, you will need to add an image to the root of your directory. In my case, I will add base_img.jpg to the directory (which will be an image from Unsplash).

We are now ready to start coding!

Applying the oil painting effect

This section simply loads the image in var base_img (assuming you are following the directory structure where the notebook is in the docs folder).

Once that is complete, we can apply the oil paiting effect with one liner of code:

We can now compare by displaying the images:

This will display the images in a window.

The original image:


After applying the effect:

After effect

When you are finished with viewing, hit escape to exit.


Today’s post demonstrated how to use the OpenCV package to programmatically apply an oil painting effect to an image.

Resources and further reading

  1. The ABCs of Pipenv
  2. OpenCV Python library
  3. Pipenv

Photo credit: dancristianp

Originally posted on my blog. To see new posts without delay, read the posts there and subscribe to my newsletter.

I write content for AWS, Kubernetes, Python, JavaScript and more. To view all the latest content, be sure to visit my blog and subscribe to my newsletter. Follow me on Twitter.



Dennis O'Keeffe

Senior Engineer @ Visibuild