Please bookmark this page to avoid losing your image tool!

Image Line Eraser With Skip Options

(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.
async function processImage(originalImg, orientation = 'horizontal', eraseSize = 1, skipSize = 1) {
    // Create a new canvas element to draw on
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Ensure the image is fully loaded to get correct dimensions
    if (!originalImg.complete) {
        await new Promise(resolve => {
            originalImg.onload = resolve;
            // In case the image is already loaded but not marked as complete
            if (originalImg.naturalWidth) resolve(); 
        });
    }

    const width = originalImg.naturalWidth || originalImg.width;
    const height = originalImg.naturalHeight || originalImg.height;

    // Set canvas dimensions to match the image
    canvas.width = width;
    canvas.height = height;

    // Draw the original image onto the canvas
    ctx.drawImage(originalImg, 0, 0, width, height);

    // Sanitize parameters to ensure they are valid, non-negative integers
    let numEraseSize = parseInt(eraseSize, 10);
    if (isNaN(numEraseSize) || numEraseSize < 0) {
        numEraseSize = 1; // Fallback to an erase size of 1
    }

    let numSkipSize = parseInt(skipSize, 10);
    if (isNaN(numSkipSize) || numSkipSize < 0) {
        numSkipSize = 1; // Fallback to a skip size of 1
    }

    // If there's nothing to erase, we can return the canvas as is
    if (numEraseSize === 0) {
        return canvas;
    }

    // Get the pixel data from the entire canvas
    const imageData = ctx.getImageData(0, 0, width, height);
    const data = imageData.data; // This is a Uint8ClampedArray: [R,G,B,A, R,G,B,A, ...]

    // The total length of one "erase and skip" cycle
    const cycleLength = numEraseSize + numSkipSize;
    
    // Process based on the orientation
    if (orientation === 'horizontal') {
        // Iterate through each row of pixels (y-axis)
        for (let y = 0; y < height; y++) {
            // Check if the current row falls within the "erase" part of the cycle
            if (y % cycleLength < numEraseSize) {
                // If so, make every pixel in this row transparent
                for (let x = 0; x < width; x++) {
                    // Calculate the starting index of the pixel's alpha component in the data array
                    const alphaIndex = (y * width + x) * 4 + 3;
                    // Set the alpha value to 0 (fully transparent)
                    data[alphaIndex] = 0;
                }
            }
        }
    } else { // Assumes 'vertical' orientation
        // Iterate through each column of pixels (x-axis)
        for (let x = 0; x < width; x++) {
            // Check if the current column falls within the "erase" part of the cycle
            if (x % cycleLength < numEraseSize) {
                // If so, make every pixel in this column transparent
                for (let y = 0; y < height; y++) {
                    const alphaIndex = (y * width + x) * 4 + 3;
                    data[alphaIndex] = 0;
                }
            }
        }
    }

    // Put the modified pixel data back onto the canvas
    ctx.putImageData(imageData, 0, 0);

    // Return the final canvas element
    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 Line Eraser With Skip Options tool allows users to selectively erase horizontal or vertical lines from an image while skipping certain lengths in between. This can be particularly useful for creating visual patterns or effects, such as simulating line art or preparing images for creative projects. The tool provides flexibility in terms of the size of the erased segments and the skipped segments, making it suitable for designers, artists, and anyone looking to manipulate images in a controlled manner.

Leave a Reply

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

Other Image Tools:

Image Nth Line Eraser

Image To SVG Converter

Image Digitizer From Scan

Image Design for 10×4 Meter Landscape LED Screen with Running Video

Photo Custom Text Editor for Identification Cards

Image Outline Detection and Marking Tool

Image Diagonal Golden Ratio Overlay Tool

Image Line Drawer and Eraser

Image To Binary Converter For Optimized Storage

Image Japanese Anime Cell Shading Tool

Image Japanese Anime Cel Shading Renderer for Military Vehicles

Image Anime Cel Shade Effect Generator

Image Liquid Metallic Chrome Material Top View

Image Generator for Rainbow Six Siege Logo with Rainbow Fill

Image Transparency Adjuster for Clothing

Photo VHS Found Footage Analog Effect Tool

Image Old Fashioned Wanted Poster Creator

Image Toxic Waste Identifier

Image Realism Enhancer

Image Bulk Date and Location Stamp Adder Without Background Color

Image Time Stamp Removal Tool

Image Bulk Date and Text Stamp Adder

Image Bulk Date and Location Stamp Adder

Image Date and Location Stamp Adder

Image Date and Zone Stamping Tool

Image Bulk Date and Location Stamper

Image Bulk Date and Coordinate Stamper

Photo Artificial Metadata Generator

Photo Artificial Pattern Generator for Deepfake Bypass

Image Ultra Realistic Skin Texture Pore Emulation Tool

Image Chaotic Noise and Blur Generator for Deepfake Detection Evasion

Image Deep Effects Modification Tool

Image Portrait to Classic Hollywood Cinematic Still Enhancer

Image Chaotic Deep Modifications Editor

Image Chaotic Interleaving Modifier

Image Random Effects Generator with Low Intensity

See All →