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




Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem

Recommended from Medium

Samanar Hills — Keelakuyilkudi

Set up for Uploading videos to Go pro Cloud

Celebrate Your African Heritage with the Africa Inspiration Calendar, by Kenyan Photographer…

Photos taken from my Attic (Part 5)

Solve Birthstone Wishing Balls — Gratitude Globe

A Different Sort of Blue

PDF @ Download !! Photography: A Cultural History #*BOOK

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
Rahul Prabhu

Rahul Prabhu

I write and code about all kinds of stuff:

More from Medium

Pytorch for Beginners 💫

Deep Transfer Learning on the Animals-10 Dataset in PyTorch

Image Segmentation — An Overview On How Its Algorithms Identify Objects In An Image

Automatic Liver Segmentation — Part 2/4: Data Preparation and Preprocess