Convert Photo to Line Drawing: 6 Proven Methods
Turning a photo into a line drawing strips away color and shading to reveal pure structure — edges, contours, and shapes. The result looks hand-drawn, like someone traced the photo with a fine-tipped pen. People use this effect for illustration references, coloring pages, tattoo design mockups, stencils for screen printing, architectural visualization, and T-shirt graphics.
The methods range from a 30-second Photoshop trick to a 10-line Python script. Each produces a noticeably different style of line art, so the "best" method depends on whether you want a soft pencil sketch, hard binary edges, or something in between. Here are six approaches, compared side by side.
Quick Comparison: Methods at a Glance
| Method | Style | Batch Support | Cost | Best For |
|---|---|---|---|---|
| Photoshop (v26.3) | Soft pencil sketch | Via Actions | $22.99/mo | Realistic hand-drawn look |
| GIMP (v2.10.38) | Hard binary edges | Via Script-Fu | Free | Clean, high-contrast line art |
| Python OpenCV (v4.9.0) | Configurable edges | Yes (scripted) | Free | Batch processing, automation |
| Prisma (iOS/Android) | Artistic/stylized | One at a time | Free (watermark) | Quick mobile results |
| Online tools (Fotor, pho.to) | Varies | Limited | Free/freemium | No install, one-off use |
| CSS/SVG filters | Soft edges, browser-rendered | N/A | Free | Live web effects without file conversion |
Try it yourself
Convert between any image format instantly — free, instant, no signup. Your images never leave your browser.
Photoshop: The Pencil Sketch Effect (v26.3)
This is the classic method. It produces a soft, realistic pencil-sketch look by combining layer blending modes. The entire process takes about 60 seconds once you know the steps.
Steps
- Open your photo in Photoshop v26.3.
- Duplicate the background layer (Ctrl+J / Cmd+J).
- Desaturate the duplicate: Image > Adjustments > Desaturate (or Shift+Ctrl+U). This converts the layer to grayscale without changing the color mode.
- Duplicate the desaturated layer (Ctrl+J).
- Invert the new duplicate: Ctrl+I / Cmd+I.
- Set the inverted layer's blend mode to Color Dodge. The canvas will appear almost entirely white — that is expected.
- Apply Filter > Blur > Gaussian Blur to the inverted layer. Start with a radius of 20-30px and adjust. As you increase the radius, pencil-like lines emerge from the white.
The Gaussian Blur radius controls line thickness. Lower values (10-15px) produce fine, detailed lines. Higher values (40-60px) create bolder, sketchier strokes. For portraits, 20-30px typically hits the sweet spot.
Pro tip: Add a Levels adjustment layer on top and pull the midpoint slider right to increase contrast and remove faint gray artifacts. This makes the lines crisper against a clean white background.
Why This Works
Color Dodge divides the bottom layer by the inverse of the top layer. When the top layer (inverted) is nearly identical to the bottom (desaturated), the result is pure white — the values cancel out. Blurring the top layer introduces slight pixel mismatches along edges, and those mismatches survive the division. Edges appear as dark lines; flat areas stay white.
GIMP: Edge Detection + Threshold (v2.10.38)
GIMP's approach produces harder, more defined edges — closer to a pen drawing than a pencil sketch. The result is black and white with no gray midtones.
Steps
- Open your image in GIMP v2.10.38.
- Convert to grayscale: Colors > Desaturate > Luminosity.
- Detect edges: Filters > Edge-Detect > Edge. Use the default (Sobel) algorithm with Amount: 1.0.
- Invert the result: Colors > Invert. Edges should now be dark lines on a white background.
- Increase contrast: Colors > Threshold. Drag the slider until you have clean lines without noise. A value around 120-140 works for most photos.
- Export as PNG.
For a softer result, skip the Threshold step and instead adjust Colors > Curves to increase contrast while preserving some gray tones. This keeps lighter sketch-like detail that Threshold would destroy.
Alternative edge detector: Try Filters > Edge-Detect > Difference of Gaussians with Inner radius 1.0 and Outer radius 5.0. This often produces cleaner lines on photos with subtle edges (like faces) where Sobel can be noisy.
Python with OpenCV: Canny Edge Detection (v4.9.0)
For batch processing or automation, Python with OpenCV gives you full control over every parameter. The Canny edge detector finds edges by looking for sharp intensity gradients, then applies non-maximum suppression and hysteresis thresholding to keep only the meaningful ones.
Pencil Sketch Script
# Requires: opencv-python==4.9.0.80, numpy>=1.26.0
import cv2
import numpy as np
def photo_to_sketch(input_path: str, output_path: str, blur_ksize: int = 21) -> None:
"""Convert a photo to a pencil sketch effect."""
img = cv2.imread(input_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
inverted = cv2.bitwise_not(gray)
blurred = cv2.GaussianBlur(inverted, (blur_ksize, blur_ksize), sigmaX=0)
sketch = cv2.divide(gray, cv2.bitwise_not(blurred), scale=256.0)
cv2.imwrite(output_path, sketch)
photo_to_sketch("portrait.jpg", "sketch.png", blur_ksize=31)
This mirrors the Photoshop method — grayscale, invert, blur, divide. The blur_ksize parameter controls line thickness (must be odd). Higher values = bolder lines.
Clean Edge Detection Script
# Requires: opencv-python==4.9.0.80
import cv2
def photo_to_line_art(input_path: str, output_path: str,
low: int = 50, high: int = 150) -> None:
"""Convert a photo to binary line art using Canny edge detection."""
img = cv2.imread(input_path, cv2.IMREAD_GRAYSCALE)
# Bilateral filter preserves edges while smoothing flat areas
smooth = cv2.bilateralFilter(img, d=9, sigmaColor=75, sigmaSpace=75)
edges = cv2.Canny(smooth, threshold1=low, threshold2=high)
# Invert so edges are dark on white
line_art = cv2.bitwise_not(edges)
cv2.imwrite(output_path, line_art)
photo_to_line_art("building.jpg", "line_art.png", low=30, high=100)
The bilateral filter is the key preprocessing step. It smooths noise and flat color regions without blurring edges, so Canny detects real contours rather than texture noise. The low and high thresholds control edge sensitivity — lower values pick up more detail (and more noise), higher values keep only the strongest edges.
Batch Processing
from pathlib import Path
input_dir = Path("photos")
output_dir = Path("sketches")
output_dir.mkdir(exist_ok=True)
for photo in input_dir.glob("*.jpg"):
photo_to_sketch(str(photo), str(output_dir / f"{photo.stem}_sketch.png"))
This processes an entire folder in seconds. For large batches, you can compress the output images afterward to keep file sizes manageable.
Prisma (iOS / Android)
Prisma applies neural style transfer — a trained model repaints your photo in the style of a specific art movement. Several of its built-in filters produce line-drawing or sketch effects: Curly Hair, Heisenberg, and Light Summer Sketch are the closest to a pencil drawing.
Steps
- Install Prisma from the App Store or Google Play (free, with watermark on free tier).
- Open a photo and swipe through filters.
- Look under the Art or Sketch categories for line-drawing styles.
- Adjust intensity with the slider — lower intensity preserves more of the original photo's detail.
- Save or share. Free exports include a small watermark; Prisma Premium ($7.99/mo) removes it.
Prisma's output is artistic rather than precise. It does not extract edges mathematically — it reinterprets the image through a neural network. The results look distinctive and hand-crafted, but they are not suitable for technical use cases like stencils or architectural line drawings.
Online Tools: No Installation Required
Two free browser-based options handle quick one-off conversions:
Fotor (fotor.com): Upload a photo, navigate to the AI Effects section, and select a sketch style. The free tier applies a watermark; the Pro plan ($8.99/mo) removes it. Results lean toward artistic interpretation.
pho.to (funny.pho.to/sketch): A free tool that converts photos to pencil sketches with no account required. Upload, pick a sketch style, download. Quality varies by photo — high-contrast portraits produce the best results. No batch support.
Both tools upload your image to a remote server for processing. If image privacy matters, the Photoshop, GIMP, or Python methods keep everything local. You can also convert between formats and resize directly in your browser with Pixotter — no upload required.
CSS/SVG Filters: Live Line Art on the Web
You can approximate a line-drawing effect directly in the browser using CSS and SVG filters. This is useful for hover effects, art galleries, or any context where you want the conversion to happen at render time without creating a new file.
/* Sketch-like effect using CSS filter stacking */
.sketch-effect {
filter: grayscale(1) contrast(2) brightness(1.1);
mix-blend-mode: multiply;
}
/* Stronger edge effect with SVG filter */
.line-art {
filter: url(#edge-detect) grayscale(1) contrast(3);
}
<svg width="0" height="0">
<filter id="edge-detect">
<feConvolveMatrix order="3"
kernelMatrix="-1 -1 -1 -1 8 -1 -1 -1 -1"
preserveAlpha="true" />
</filter>
</svg>
The SVG feConvolveMatrix with a Laplacian kernel (center = 8, surrounding = -1) acts as an edge detector. Combined with high contrast and grayscale, it produces a rough line-drawing effect. It will not match the quality of Photoshop or OpenCV, but it requires zero server processing and works in Chrome 53+, Firefox 35+, Safari 9.1+, and Edge 79+.
For more advanced image effects on the web, sharpening and vectorization are related techniques worth exploring.
Use Cases for Line Drawing Conversion
| Use Case | Recommended Method | Why |
|---|---|---|
| Coloring pages | GIMP (Edge Detect + Threshold) | Clean binary lines print well |
| Pencil sketch portrait | Photoshop (Color Dodge) | Most realistic hand-drawn appearance |
| Tattoo design reference | OpenCV (Canny, tight thresholds) | Precise, adjustable edges |
| T-shirt / stencil design | GIMP or OpenCV (high contrast) | Needs solid black on white |
| Architectural sketch | OpenCV (bilateral + Canny) | Handles straight lines and geometry well |
| Art prints | Prisma (neural style) | Distinctive artistic interpretation |
| Illustration reference | Photoshop or OpenCV sketch | Preserves proportions and shading detail |
| Web hover effect | CSS/SVG filter | No file conversion needed |
Once you have your line art, you can change the background color to place it on a colored canvas, or vectorize it to convert the raster line drawing into a scalable SVG.
Tips for Better Line Drawing Results
- Start with high-contrast photos. The algorithms detect edges based on brightness differences. Low-contrast photos produce faint, noisy lines. Increase contrast or adjust levels before converting.
- Portraits work best. Faces have strong, well-defined edges (eyes, nose, jawline) that every method handles well. Landscapes with soft gradients (clouds, fog) produce messy results.
- Remove the background first. A busy background adds clutter to the line art. Isolate the subject first — tools like Pixotter's background removal handle this in seconds.
- Use bilateral filtering before edge detection. In OpenCV and GIMP, smoothing the photo while preserving edges dramatically reduces noise in the output.
- Match method to output format. If the line art will be printed, use a binary (black-and-white) method for sharp results at any DPI. If it will be displayed on screen, the softer pencil-sketch effect looks more natural.
FAQ
What is the easiest way to convert a photo to a line drawing?
The fastest option with no software to install: upload to pho.to's sketch tool or Fotor's AI effects. For desktop users, the Photoshop Color Dodge method takes under a minute and produces the most natural pencil-sketch look.
Can I convert a photo to a line drawing for free?
Yes. GIMP is free and open source (GPL-3.0), and the edge detection method produces excellent results. Python with OpenCV is also free and handles batch processing. Online tools like pho.to offer free conversions with no account required.
Which method produces the most realistic pencil sketch?
The Photoshop Color Dodge + Gaussian Blur technique. It simulates the way a pencil deposits graphite — heavier along edges, lighter across flat areas. The OpenCV divide-based sketch script produces a nearly identical result programmatically.
How do I convert a photo to line art for a tattoo design?
Use OpenCV's Canny edge detection with tight thresholds (low=30, high=80) and bilateral filtering. This gives you clean, precise lines that a tattoo artist can use as a reference. Export at high resolution (300 DPI minimum) on a pure white background.
Can I batch-convert hundreds of photos to line drawings?
Yes. The Python OpenCV scripts above process entire folders in seconds. Wrap the conversion function in a loop over your input directory. For post-processing, compress the output images to reduce storage requirements.
What image format should I save line drawings in?
PNG for line art with solid black lines on white — it compresses binary patterns efficiently with lossless quality. Avoid JPEG, which introduces artifacts around sharp edges. If you need a scalable version, vectorize the line drawing to SVG.
Why does my line drawing look noisy instead of clean?
The source photo likely has low contrast, JPEG compression artifacts, or a busy background. Fix it by: (1) increasing contrast before conversion, (2) applying bilateral or Gaussian blur to smooth noise, (3) isolating the subject from the background, or (4) raising the Canny/Threshold values to filter out weak edges.
Can I convert a line drawing back to a photo?
Not from the line drawing alone — edge detection is a destructive, lossy process. The color, shading, and texture information is gone. AI image generation tools (Stable Diffusion's ControlNet, for example) can generate a new photo guided by line art, but the result is a new image, not a reconstruction of the original.
Try it yourself
Ready to convert formats? Drop your image and get results in seconds — free, instant, no signup. Your images never leave your browser.