Analytics Vidhya
Published in

Analytics Vidhya

Convert any image to a pencil sketch — with just 2 lines of code!

Create beautiful realistic pencil sketches with the package sketchify in Python.

Creating a realistic pencil sketch by hand requires hours of agonizing work: from converting textures, perfecting shadows, to the tiniest of details. Now, you can create realistic pencil sketches in Python — using only two lines of code!


First, install the package sketchify using pip in cmd:

pip install sketchify

Open a new Python file, and write this:

That’s it! We only need two lines of code to convert any image to a pencil sketch. Sketchify saves the image as a png file, so the Sketchified image will be saved in the folder specified (path/to/save) as image.png.

The beauty of Sketchify is that it can convert any photo into a realistic pencil sketch. If you use an HD image, you get extra texture, detailed shadows, and a lot more.


Advanced Features

You can change the scale of the image to darken the image. Note that on lighter scales, the greater texture is achieved. You can change the scale in the scale parameter of the normalsketch function. Note that the scale needs to be an integer value between 1 and 10.

To tweak the scale, simply add the parameter scale to the existing code:

sketch.normalsketch(‘pathtoimage’, ‘savepath’, ‘savename’, scale=x)

The default value for the scale is 10.

Tweaking the scale parameter allows you to change the image ‘darkness’ from extremely light to dark:

Scale: 1 vs 5 vs 10

Notice that there is a difference in texture, particularly the shading. In smaller pictures or pictures of poor quality, it is recommended that you don’t keep the scale to the extremes of 1 or 10.


The GitHub repository for this package is available at In the near future, effects like chalk, cartoon, and different artwork styles will be added, so be sure to keep checking in! Sketchify is also looking for contributors, so feel free to dro pa note if you are interested :).

©Rahul Prabhu 2020



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store