Please bookmark this page to avoid losing your image tool!

Image To Google Search 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, endpoint = "https://lens.google.com/upload") {
    // Create the main container div
    const container = document.createElement('div');
    container.style.fontFamily = 'system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
    container.style.display = 'flex';
    container.style.flexDirection = 'column';
    container.style.alignItems = 'center';
    container.style.justifyContent = 'center';
    container.style.padding = '24px';
    container.style.border = '1px solid #e0e0e0';
    container.style.borderRadius = '12px';
    container.style.backgroundColor = '#ffffff';
    container.style.boxShadow = '0 4px 12px rgba(0,0,0,0.05)';
    container.style.maxWidth = '320px';
    container.style.margin = 'auto';

    // Title
    const title = document.createElement('h3');
    title.textContent = 'Reverse Image Search';
    title.style.margin = '0 0 16px 0';
    title.style.color = '#202124';
    title.style.fontSize = '18px';
    container.appendChild(title);

    // Image Preview Wrapper
    const imgWrapper = document.createElement('div');
    imgWrapper.style.width = '100%';
    imgWrapper.style.height = '200px';
    imgWrapper.style.display = 'flex';
    imgWrapper.style.alignItems = 'center';
    imgWrapper.style.justifyContent = 'center';
    imgWrapper.style.marginBottom = '20px';
    imgWrapper.style.backgroundColor = '#f8f9fa';
    imgWrapper.style.borderRadius = '8px';
    imgWrapper.style.overflow = 'hidden';
    imgWrapper.style.border = '1px dashed #dadce0';

    // Image Preview
    const imgPreview = document.createElement('img');
    imgPreview.src = originalImg.src;
    imgPreview.style.maxWidth = '100%';
    imgPreview.style.maxHeight = '100%';
    imgPreview.style.objectFit = 'contain';
    imgWrapper.appendChild(imgPreview);
    container.appendChild(imgWrapper);

    // Form to POST directly to Google Lens
    const form = document.createElement('form');
    form.action = endpoint;
    form.method = 'POST';
    form.enctype = 'multipart/form-data';
    form.target = '_blank'; // Important: opens in a new tab to bypass CORS policies naturally 
    form.style.display = 'flex';
    form.style.justifyContent = 'center';
    form.style.width = '100%';

    // File input required by Google endpoint
    const fileInput = document.createElement('input');
    fileInput.type = 'file';
    fileInput.name = 'encoded_image';
    fileInput.style.display = 'none';
    form.appendChild(fileInput);

    // Submit Button
    const searchIconText = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 24 24" style="margin-right: 8px; vertical-align: middle;"><path d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 0 0 1.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 0 0-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 0 0 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>`;
    const submitBtn = document.createElement('button');
    submitBtn.type = 'submit';
    submitBtn.innerHTML = `${searchIconText}<span style="vertical-align: middle;">Search on Google</span>`;
    submitBtn.disabled = true;
    submitBtn.style.padding = '12px 20px';
    submitBtn.style.border = 'none';
    submitBtn.style.borderRadius = '24px';
    submitBtn.style.backgroundColor = '#1a73e8';
    submitBtn.style.color = '#fff';
    submitBtn.style.fontSize = '14px';
    submitBtn.style.fontWeight = '500';
    submitBtn.style.cursor = 'not-allowed';
    submitBtn.style.width = '100%';
    submitBtn.style.opacity = '0.7';
    submitBtn.style.transition = 'all 0.2s';
    submitBtn.style.boxShadow = '0 1px 2px 0 rgba(60,64,67,0.3)';

    submitBtn.onmouseover = () => { if (!submitBtn.disabled) submitBtn.style.backgroundColor = '#1557b0'; };
    submitBtn.onmouseout = () => { if (!submitBtn.disabled) submitBtn.style.backgroundColor = '#1a73e8'; };

    form.appendChild(submitBtn);
    container.appendChild(form);

    // Asynchronously extract blob from image and stuff it into the file input using DataTransfer
    setTimeout(() => {
        try {
            const canvas = document.createElement('canvas');
            const width = originalImg.naturalWidth || originalImg.width || 300;
            const height = originalImg.naturalHeight || originalImg.height || 150;
            
            canvas.width = width;
            canvas.height = height;
            
            const ctx = canvas.getContext('2d');
            ctx.drawImage(originalImg, 0, 0, width, height);

            canvas.toBlob((blob) => {
                if (blob) {
                    try {
                        const file = new File([blob], 'search_image.jpg', { type: 'image/jpeg' });
                        
                        // Using DataTransfer to attach constructed file to the input purely via clientside
                        const dataTransfer = new DataTransfer();
                        dataTransfer.items.add(file);
                        fileInput.files = dataTransfer.files;

                        // Activation of submit button
                        submitBtn.disabled = false;
                        submitBtn.style.cursor = 'pointer';
                        submitBtn.style.opacity = '1';
                    } catch (e) {
                        submitBtn.textContent = 'DataTransfer API not supported';
                    }
                } else {
                    submitBtn.textContent = 'Conversion issue';
                }
            }, 'image/jpeg', 0.9);
        } catch (err) {
            console.error('Canvas processing error:', err);
            // Commonly trigged if originalImg is tainted by cross-origin policies
            submitBtn.textContent = 'CORS Error encountered';
        }
    }, 10);

    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 perform a reverse image search by uploading an image directly to Google Lens. It facilitates identifying objects, finding similar images, or discovering the source of a photo. It is useful for finding products seen in pictures, identifying landmarks, or verifying the authenticity of an image online.

Leave a Reply

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