# Create pencil sketch from photo

**URL:** https://discourse.processing.org/t/create-pencil-sketch-from-photo/25997
**Category:** Coding Questions
**Created:** [December 6, 2020, 4:53pm UTC](https://discourse.processing.org/t/create-pencil-sketch-from-photo/25997 "2020-12-06T16:53:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mikemcsharry](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mikemcsharry](https://discourse.processing.org/u/mikemcsharry)
#### Post date: [December 6, 2020, 4:53pm UTC](https://discourse.processing.org/t/create-pencil-sketch-from-photo/25997/1 "2020-12-06T16:53:44Z")

</div>

Hello,  
I’m trying to make a pencil sketch from a jpeg image,  
I found this code using python libraries, but know nothing about Python.  
Is there a way to do this in processing, also is there a way to do it without always showing the images?  
I’ve reached this point so far…

```auto
void setup() {
  size(800, 754);
  // The image file must be in the data folder of the current sketch 
  // to load successfully
  img = loadImage("headshot.jpg"); // Load the image into the program  
}

void draw() {
  // Displays the image at its actual size at point (0,0)
  image(img, 0, 0);
  // Displays the image at point (0, height/2) at half of its size
 
 // image(img, 0, height/10, img.width/10, img.height/10);
  //image(img, 0, 0);
  delay (2000);
 blend(img, 0, 0, 800, 754, 0, 0, 800,754, DODGE);
 //delay (3000);
 //image(img,0,0);
 //filter(INVERT);
}

```

---

<div class="post-metadata">

### Author: ![mikemcsharry](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mikemcsharry](https://discourse.processing.org/u/mikemcsharry)
#### Post date: [December 6, 2020, 6:03pm UTC](https://discourse.processing.org/t/create-pencil-sketch-from-photo/25997/2 "2020-12-06T18:03:58Z")

</div>

The steps are  
destaurate the image  
Color dodge the blend  
Invert the layer  
Apply a gaussian blur (of about 1 pixel)  
Adjust the black level

I’m not sure how to use the HSL colormode with procesing  
And also, how to get control with the gaussian layer  
I’ve been able to output a desaturated jpeg from a photo editing package to start from.

```auto
PImage img; // Declare variable "a" of type PImage

void setup() {
  noLoop();
  size(800, 754);
  // The image file must be in the data folder of the current sketch 
  // to load successfully
  img = loadImage("headshotsat1.jpg"); // Load the image into the program  
}

void draw() {
  
  // Displays the image at its actual size at point (0,0)
  image(img, 0, 0);
  // Displays the image at point (0, height/2) at half of its size
 
 // image(img, 0, height/10, img.width/10, img.height/10);
  //image(img, 0, 0);
  
 blend(img, 0, 0, 800, 754, 0, 0, 800,754, DODGE);

// image(img,800,0);
 filter(INVERT);
 // invert applies to the whole canvas
 filter(BLUR,5);
 // blur aplies to whole canvas
 
}

```
