Please bookmark this page to avoid losing your image tool!

Drag And Drop Image Options Text By Identifier VPN

(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, identifierText = "VPN-ID-001", optionsText = "Options: Enabled") {
    // Create a container to hold the image and draggable elements
    const container = document.createElement('div');
    container.style.position = 'relative';
    container.style.display = 'inline-block';
    container.style.width = originalImg.width + 'px';
    container.style.height = originalImg.height + 'px';
    container.style.overflow = 'hidden';
    container.style.fontFamily = 'Arial, sans-serif';

    // Create a canvas to draw the base original image
    const canvas = document.createElement('canvas');
    canvas.width = originalImg.width;
    canvas.height = originalImg.height;
    const ctx = canvas.getContext('2d');
    ctx.drawImage(originalImg, 0, 0);
    canvas.style.display = 'block';
    
    container.appendChild(canvas);

    // Factory function to create draggable text boxes
    function createDraggableText(text, initialX, initialY, bgColor = 'rgba(0, 0, 0, 0.7)') {
        const el = document.createElement('div');
        el.innerText = text;
        el.style.position = 'absolute';
        el.style.left = initialX + 'px';
        el.style.top = initialY + 'px';
        el.style.padding = '12px 20px';
        el.style.background = bgColor;
        el.style.color = '#ffffff';
        el.style.fontSize = '20px';
        el.style.fontWeight = 'bold';
        el.style.cursor = 'move';
        el.style.userSelect = 'none';
        el.style.border = '2px dashed #ffffff';
        el.style.borderRadius = '8px';
        el.style.boxShadow = '0px 4px 6px rgba(0,0,0,0.4)';
        el.style.backdropFilter = 'blur(4px)';
        el.style.transition = 'background 0.2s';

        let isDragging = false;
        let startX, startY, initialLeft, initialTop;

        // Mouse Drag Handler
        el.addEventListener('mousedown', (e) => {
            isDragging = true;
            startX = e.clientX;
            startY = e.clientY;
            initialLeft = parseInt(el.style.left, 10);
            initialTop = parseInt(el.style.top, 10);
            el.style.zIndex = 1000;
            el.style.background = 'rgba(0, 100, 255, 0.8)'; // Highlight on drag

            const onMouseMove = (e) => {
                if (!isDragging) return;
                const dx = e.clientX - startX;
                const dy = e.clientY - startY;
                
                let newLeft = initialLeft + dx;
                let newTop = initialTop + dy;

                // Retain inside boundaries
                newLeft = Math.max(0, Math.min(newLeft, canvas.width - el.offsetWidth));
                newTop = Math.max(0, Math.min(newTop, canvas.height - el.offsetHeight));

                el.style.left = newLeft + 'px';
                el.style.top = newTop + 'px';
            };

            const onMouseUp = () => {
                isDragging = false;
                el.style.zIndex = '';
                el.style.background = bgColor;
                document.removeEventListener('mousemove', onMouseMove);
                document.removeEventListener('mouseup', onMouseUp);
            };

            document.addEventListener('mousemove', onMouseMove);
            document.addEventListener('mouseup', onMouseUp);
        });

        // Touch Drag Handler for Mobile Devices
        el.addEventListener('touchstart', (e) => {
            isDragging = true;
            startX = e.touches[0].clientX;
            startY = e.touches[0].clientY;
            initialLeft = parseInt(el.style.left, 10);
            initialTop = parseInt(el.style.top, 10);
            el.style.zIndex = 1000;
            el.style.background = 'rgba(0, 100, 255, 0.8)';
            
            // Prevent scrolling while dragging
            e.preventDefault();

            const onTouchMove = (e) => {
                if (!isDragging) return;
                const dx = e.touches[0].clientX - startX;
                const dy = e.touches[0].clientY - startY;
                
                let newLeft = initialLeft + dx;
                let newTop = initialTop + dy;

                newLeft = Math.max(0, Math.min(newLeft, canvas.width - el.offsetWidth));
                newTop = Math.max(0, Math.min(newTop, canvas.height - el.offsetHeight));

                el.style.left = newLeft + 'px';
                el.style.top = newTop + 'px';
            };

            const onTouchEnd = () => {
                isDragging = false;
                el.style.zIndex = '';
                el.style.background = bgColor;
                document.removeEventListener('touchmove', onTouchMove);
                document.removeEventListener('touchend', onTouchEnd);
            };

            document.addEventListener('touchmove', onTouchMove, { passive: false });
            document.addEventListener('touchend', onTouchEnd);
        }, { passive: false });

        return el;
    }

    // Generate the draggable text items based on function parameters
    const identifierDragElement = createDraggableText(`Identifier: ${identifierText}`, 20, 20, 'rgba(220, 53, 69, 0.8)');
    const optionsDragElement = createDraggableText(optionsText, 20, 100, 'rgba(40, 167, 69, 0.8)');
    const instructionsElement = createDraggableText("⇱ Drag elements to reposition", 20, 180, 'rgba(52, 58, 64, 0.8)');

    // Append to container
    container.appendChild(identifierDragElement);
    container.appendChild(optionsDragElement);
    container.appendChild(instructionsElement);

    return container;
}

Free Image Tool Creator

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

Description

This tool allows users to overlay customizable text elements onto an image. It provides draggable text boxes containing specific identifiers and option descriptions that can be repositioned anywhere within the image boundaries using a mouse or touch interface. This is particularly useful for creating annotated screenshots, labeling technical diagrams, or adding dynamic overlays for presentations and documentation.

Leave a Reply

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