Please bookmark this page to avoid losing your image tool!

Cybernetic Self-Healing Image Enhancer 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.
async function processImage(originalImg, repairStrength = 0.5, artifactIntensity = 0.2, scanlineOpacity = 0.15, greenBoost = 0.35) {
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

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

    canvas.width = w;
    canvas.height = h;

    // Draw the original image
    ctx.drawImage(originalImg, 0, 0, w, h);

    if (w === 0 || h === 0) {
        console.error("Image has zero width or height.");
        return canvas; // Return empty canvas if image is invalid
    }

    const imageData = ctx.getImageData(0, 0, w, h);
    const pixels = imageData.data;

    // Helper for clamping values
    const clamp = (value) => Math.max(0, Math.min(255, value));

    // 1. Pixel-level "Healing/Enhancement" and Green Boosting
    for (let i = 0; i < pixels.length; i += 4) {
        let r = pixels[i];
        let g = pixels[i + 1];
        let b = pixels[i + 2];

        const luminance = (r * 0.299 + g * 0.587 + b * 0.114); // Weighted luminance

        let repaired_r = r;
        let repaired_g = g;
        let repaired_b = b;

        // Define thresholds before the conditional logic
        const darkThreshold = 70 + 30 * (1 - repairStrength); // Lower threshold for stronger repair
        const brightThreshold = 185 - 30 * repairStrength; // Higher threshold for weaker repair

        // Apply "Repair" based on luminance
        // If pixel is relatively dark, try to "recover" detail (brighten and add slight green emphasis)
        if (luminance < darkThreshold) {
            const factor = 1.0 + 0.4 * repairStrength; // How much to brighten
            repaired_r = clamp(r * factor);
            repaired_g = clamp(g * factor + 25 * repairStrength); // Add green hint during recovery
            repaired_b = clamp(b * factor);
        }
        // If pixel is relatively bright, "stabilize/enhance" it (subtle glow/sharpening)
        else if (luminance > brightThreshold) {
            const factor = 1.0 + 0.15 * repairStrength;
            repaired_g = clamp(g * (1 + 0.1 * repairStrength) + 20 * repairStrength); // Green glow for highlights
            repaired_r = clamp(r * factor);
            repaired_b = clamp(b * factor);
        }


        // Apply Green Boost
        pixels[i]     = clamp(repaired_r * (1 - greenBoost * 0.8)); // Reduce red
        pixels[i + 1] = clamp(repaired_g * (1 + greenBoost * 0.5) + (255 - repaired_g) * greenBoost * 0.2); // Boost existing green and overall green
        pixels[i + 2] = clamp(repaired_b * (1 - greenBoost * 0.8)); // Reduce blue
    }
    ctx.putImageData(imageData, 0, 0);


    // 2. Cybernetic Artifacts (Glitching)
    if (artifactIntensity > 0) {
        const numArtifacts = Math.floor(1 + 30 * artifactIntensity * (w/500)); // Scale with image width
        for (let k = 0; k < numArtifacts; k++) {
            try {
                const blockW = Math.max(5, Math.floor(Math.random() * w * (0.05 + artifactIntensity * 0.15)));
                const blockH = Math.max(1, Math.floor(Math.random() * h * (0.01 + artifactIntensity * 0.04)));
                
                const sourceX = Math.floor(Math.random() * (w - blockW));
                const sourceY = Math.floor(Math.random() * (h - blockH));

                const offsetX = Math.floor((Math.random() - 0.5) * 25 * artifactIntensity);
                const offsetY = Math.floor((Math.random() - 0.5) * 10 * artifactIntensity);

                let targetX = sourceX + offsetX;
                let targetY = sourceY + offsetY;
                
                // Ensure target is somewhat within bounds to see the effect mostly
                targetX = Math.max(-blockW / 2, Math.min(w - blockW / 2, targetX));
                targetY = Math.max(-blockH / 2, Math.min(h - blockH / 2, targetY));

                if (sourceX >= 0 && sourceY >= 0 && sourceX + blockW <= w && sourceY + blockH <=h) {
                    const blockImageData = ctx.getImageData(sourceX, sourceY, blockW, blockH);
                    
                    // Optionally add a slight green tint or brightness flash to the glitched block
                    if (Math.random() < 0.3) { // 30% chance to tint the glitch
                        const blockPixels = blockImageData.data;
                        for (let j = 0; j < blockPixels.length; j += 4) {
                            blockPixels[j+1] = clamp(blockPixels[j+1] + 30 + 20 * artifactIntensity);
                            blockPixels[j] = clamp(blockPixels[j] * 0.8);
                            blockPixels[j+2] = clamp(blockPixels[j+2] * 0.8);
                        }
                    }
                    ctx.putImageData(blockImageData, targetX, targetY);
                }
            } catch (e) {
                // Catch getImageData/putImageData errors if coords are out of bounds, though we try to prevent it
                // console.warn("Artifact generation error (likely out of bounds):", e);
            }
        }
    }


    // 3. Scanlines
    if (scanlineOpacity > 0) {
        ctx.fillStyle = `rgba(0, 200, 0, ${scanlineOpacity * 0.7})`; // Make scanlines slightly less opaque than parameter suggests
        const scanlineThickness = 1;
        const scanlineSpacing = Math.max(2, Math.floor(5 - scanlineOpacity * 3)); // Denser for higher opacity
        for (let j = 0; j < h; j += scanlineSpacing) {
            ctx.fillRect(0, j, w, scanlineThickness);
        }
    }
    
    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 Cybernetic Self-Healing Image Enhancer Tool is designed to enhance and repair images by applying various adjustments such as ‘healing’ darker areas to recover detail, boosting green tones, and stabilizing brighter parts. It features options for adding artistic cybernetic artifacts that mimic glitches, as well as creating scanline effects for a stylized appearance. This tool is useful for photographers looking to improve image quality, digital artists aiming to add unique effects to their creations, and anyone who wants to enhance their images before sharing or printing.

Leave a Reply

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