Please bookmark this page to avoid losing your image tool!

Image Pencil Drawing Tool

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
function processImage(originalImg, strokeSize = "5", intensity = "3") {
    let blurNum = Math.max(0, Math.min(Number(strokeSize) || 5, 100));
    let darkenNum = Math.max(0, Math.min(Number(intensity) || 3, 20));

    const w = originalImg.width;
    const h = originalImg.height;

    // Create a flattened source canvas to avoid issues with transparent PNGs
    const srcCanvas = document.createElement('canvas');
    srcCanvas.width = w;
    srcCanvas.height = h;
    const sCtx = srcCanvas.getContext('2d');
    
    // Fill background with white, then draw original image over it
    sCtx.fillStyle = '#ffffff';
    sCtx.fillRect(0, 0, w, h);
    sCtx.drawImage(originalImg, 0, 0, w, h);

    // Create a base canvas for the core sketch effect 
    // Uses the classic Color Dodge blend of grayscale + inverted blurred grayscale
    const baseCanvas = document.createElement('canvas');
    baseCanvas.width = w;
    baseCanvas.height = h;
    const bCtx = baseCanvas.getContext('2d');

    // Draw base grayscale version
    bCtx.filter = 'grayscale(100%)';
    bCtx.drawImage(srcCanvas, 0, 0, w, h);

    // Apply color-dodge and render the inverted & blurred layer
    bCtx.globalCompositeOperation = 'color-dodge';
    bCtx.filter = `grayscale(100%) invert(100%) blur(${blurNum}px)`;
    bCtx.drawImage(srcCanvas, 0, 0, w, h);

    // Final canvas to adjust edge darkness/intensity
    const finalCanvas = document.createElement('canvas');
    finalCanvas.width = w;
    finalCanvas.height = h;
    const fCtx = finalCanvas.getContext('2d');

    // Draw the initial light sketch
    fCtx.drawImage(baseCanvas, 0, 0, w, h);
    
    // Switch to multiply blend mode to darken pencil strokes without muddying whites
    fCtx.globalCompositeOperation = 'multiply';

    // Layer multiple times based on requested intensity
    for (let i = 0; i < darkenNum; i++) {
        fCtx.drawImage(baseCanvas, 0, 0, w, h);
    }

    return finalCanvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

The Image Pencil Drawing Tool transforms standard photographs into stylized pencil sketches. By utilizing adjustable stroke size and intensity settings, users can control the blur and darkness of the resulting drawing to achieve different artistic effects. This tool is useful for creative photo editing, creating artistic avatars, or converting portraits into hand-drawn style illustrations for social media and digital art projects.

Leave a Reply

Your email address will not be published. Required fields are marked *