Please bookmark this page to avoid losing your image tool!

Image Japanese Anime-Style Generator

(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.
/**
 * Applies a Japanese Anime-style filter to an image.
 * This effect is achieved through a combination of posterization (cel shading),
 * edge detection for outlines, and color enhancements.
 *
 * @param {HTMLImageElement} originalImg The original image element.
 * @param {number} [posterizationLevels=5] The number of color levels for the cel shading effect (2-255). Lower values create a more stylized, cartoonish look.
 * @param {number} [outlineThickness=2] The thickness of the black outlines in pixels. Set to 0 to disable outlines.
 * @param {number} [outlineThreshold=50] The sensitivity for edge detection (0-255). A lower value detects more subtle edges.
 * @param {number} [saturation=1.2] A multiplier for color saturation. 1.0 is original, >1.0 increases saturation.
 * @param {number} [brightness=1.1] A multiplier for image brightness. 1.0 is original, >1.0 increases brightness.
 * @returns {HTMLCanvasElement} A new canvas element with the anime-style filter applied.
 */
function processImage(originalImg, posterizationLevels = 5, outlineThickness = 2, outlineThreshold = 50, saturation = 1.2, brightness = 1.1) {
    // 1. SETUP: Create canvases and get dimensions
    const width = originalImg.naturalWidth;
    const height = originalImg.naturalHeight;

    const canvas = document.createElement('canvas');
    canvas.width = width;
    canvas.height = height;
    const ctx = canvas.getContext('2d');

    const tempCanvas = document.createElement('canvas');
    tempCanvas.width = width;
    tempCanvas.height = height;
    const tempCtx = tempCanvas.getContext('2d', {
        willReadFrequently: true
    });

    // Ensure parameters are valid numbers
    const pLevels = Number(posterizationLevels) || 5;
    const oThick = Number(outlineThickness) || 0;
    const oThresh = Number(outlineThreshold) || 50;
    const sat = Number(saturation) || 1.0;
    const brt = Number(brightness) || 1.0;

    // 2. CEL SHADING: Apply color adjustments and posterization
    // Apply saturation and brightness filters
    tempCtx.filter = `saturate(${sat}) brightness(${brt})`;
    tempCtx.drawImage(originalImg, 0, 0, width, height);
    tempCtx.filter = 'none'; // Reset filter

    // Get pixel data from the adjusted image
    const adjustedImageData = tempCtx.getImageData(0, 0, width, height);
    const posterizedData = tempCtx.createImageData(width, height);
    const data = adjustedImageData.data;
    const pData = posterizedData.data;

    // Posterization logic to reduce color palette
    const levels = Math.max(2, Math.min(255, parseInt(pLevels)));
    const step = 255 / (levels - 1);

    for (let i = 0; i < data.length; i += 4) {
        pData[i] = Math.round(data[i] / step) * step;
        pData[i + 1] = Math.round(data[i + 1] / step) * step;
        pData[i + 2] = Math.round(data[i + 2] / step) * step;
        pData[i + 3] = data[i + 3]; // Preserve alpha
    }

    // Draw the posterized base layer onto the final canvas
    ctx.putImageData(posterizedData, 0, 0);

    // 3. OUTLINES: Detect edges, thicken them, and composite
    if (oThick > 0) {
        // Step A: Create a grayscale version of the original image for edge detection
        tempCtx.clearRect(0, 0, width, height);
        tempCtx.filter = 'grayscale(1)';
        tempCtx.drawImage(originalImg, 0, 0, width, height);
        tempCtx.filter = 'none';
        const grayscale = tempCtx.getImageData(0, 0, width, height);
        const grayData = grayscale.data;

        // Step B: Perform edge detection by checking brightness difference of neighboring pixels
        const outlineData = tempCtx.createImageData(width, height);
        const oData = outlineData.data;
        const threshold = parseInt(oThresh);

        for (let y = 0; y < height; y++) {
            for (let x = 0; x < width; x++) {
                const i = (y * width + x) * 4;
                const current = grayData[i];
                let isEdge = false;

                if (x < width - 1) {
                    const right = grayData[i + 4];
                    if (Math.abs(current - right) > threshold) {
                        isEdge = true;
                    }
                }
                if (y < height - 1) {
                    const bottom = grayData[i + width * 4];
                    if (Math.abs(current - bottom) > threshold) {
                        isEdge = true;
                    }
                }

                if (isEdge) {
                    oData[i] = oData[i + 1] = oData[i + 2] = 0; // Black
                    oData[i + 3] = 255; // Opaque
                }
            }
        }

        // Step C: Thicken the outlines using a blur and threshold technique
        // Use a second temporary canvas because drawing a canvas with a filter onto itself is problematic
        const tempCanvas2 = document.createElement('canvas');
        tempCanvas2.width = width;
        tempCanvas2.height = height;
        const tempCtx2 = tempCanvas2.getContext('2d');
        tempCtx2.putImageData(outlineData, 0, 0);

        tempCtx.clearRect(0, 0, width, height);
        tempCtx.filter = `blur(${oThick}px)`;
        tempCtx.drawImage(tempCanvas2, 0, 0, width, height);
        tempCtx.filter = 'none';

        const blurredOutline = tempCtx.getImageData(0, 0, width, height);
        const bData = blurredOutline.data;

        // Threshold the alpha channel of the blurred outline to make it a hard edge
        for (let i = 0; i < bData.length; i += 4) {
            if (bData[i + 3] > 128) {
                bData[i] = bData[i + 1] = bData[i + 2] = 0;
                bData[i + 3] = 255;
            } else {
                bData[i + 3] = 0;
            }
        }
        tempCtx.putImageData(blurredOutline, 0, 0);

        // Step D: Composite the final outlines onto the main canvas
        ctx.drawImage(tempCanvas, 0, 0, width, height);
    }

    // 4. RETURN FINAL CANVAS
    return canvas;
}

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 Japanese Anime-Style Generator allows users to transform their images into a stylized anime-art appearance. By applying filters such as posterization for cel shading, edge detection to create outlines, and adjustments for color saturation and brightness, this tool can create striking visuals reminiscent of anime art. This is particularly useful for artists looking to reinterpret their works in anime style, for social media users wanting to enhance their profile pictures, or for anyone interested in adding a unique and creative touch to their images.

Leave a Reply

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

Other Image Tools:

3D Cartoon Style Image Creator

Image To Pixel-Style Converter

Image Black And White HUD Style With VHS Effects

Black and White MQ1 Reaper Drone Targeting Pod Image

Image Filter for MQ1 Reaper Drone Targeting Pod

Image Hyper-Realistic Portrait Triptych Generator

Image To Professional Architectural Render Blueprint Converter

Image Ultraviolet Camera Filter

Image Portrait Generator with Warm Golden Hour Lighting

Image Softly Lit Portrait Generator

Image Petal Count Identifier

Image Ball Creator

Image To CAD-Style Blueprint Converter

Image To Blueprint CAD Style Converter

Image To Clean CAD Blueprint Generator

Image To CAD Blueprint Generator

Image To Technical Blueprint Style Converter

Image To Blueprint-Style Drawing Converter

Image To Technical Blueprint Converter

Architectural Plan to Technical Blueprint Image Converter

Architectural Plan To Blueprint-Style Image Converter

Image To Blueprint Architectural Style Converter

Image Background Replacement To White

Image To Dot Outline Converter

Image To Vertical Halftone Converter

Image Transparent Hologram Effect Generator

Image Blue Twilight Filter Applicator

Image Golden Ratio Spiral Generator for A4

Photo Black and White Floyd-Steinberg Dithering for Acrylic Engraving

Image Cover Texture Generator

Image Arabic Text Overlay Tool

Image Arabic Style Enhancer

Arabic Style Image Designer

Image Heart Music Note Creator

Image CRT Lens Effect Enhancer for Nostalgic Wallpaper Design

Image Security Camera Effect Creator

See All →