Please bookmark this page to avoid losing your image tool!

Slow Motion Video From Image Creator

(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, durationSec = "4", zoomFactor = "1.15") {
    // 1. Create a container for the UI
    const container = document.createElement('div');
    container.style.display = 'flex';
    container.style.flexDirection = 'column';
    container.style.alignItems = 'center';
    container.style.justifyContent = 'center';
    container.style.fontFamily = 'system-ui, -apple-system, sans-serif';
    container.style.gap = '16px';
    container.style.padding = '20px';
    container.style.backgroundColor = '#1a1a1a';
    container.style.color = '#ffffff';
    container.style.borderRadius = '8px';

    // 2. Set up the canvas and cap resolution at 720p for performance & stability with MediaRecorder
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d', { alpha: false });
    
    const maxDimension = 1280;
    let width = originalImg.naturalWidth;
    let height = originalImg.naturalHeight;
    
    if (width > maxDimension || height > maxDimension) {
        if (width > height) {
            height = Math.round((height / width) * maxDimension);
            width = maxDimension;
        } else {
            width = Math.round((width / height) * maxDimension);
            height = maxDimension;
        }
    }
    
    canvas.width = width;
    canvas.height = height;
    canvas.style.maxWidth = '100%';
    canvas.style.maxHeight = '60vh';
    canvas.style.objectFit = 'contain';
    canvas.style.border = '1px solid #333';
    canvas.style.borderRadius = '4px';
    canvas.style.backgroundColor = '#000';

    // 3. UI elements for progress / status
    const statusContainer = document.createElement('div');
    statusContainer.style.display = 'flex';
    statusContainer.style.flexDirection = 'column';
    statusContainer.style.alignItems = 'center';
    statusContainer.style.gap = '8px';
    statusContainer.style.width = '100%';

    const statusLabel = document.createElement('span');
    statusLabel.textContent = "Recording slow motion video...";
    statusLabel.style.fontWeight = "bold";
    statusLabel.style.fontSize = "16px";
    statusLabel.style.textAlign = "center";

    const progressBar = document.createElement('div');
    progressBar.style.width = '100%';
    progressBar.style.maxWidth = '400px';
    progressBar.style.height = '6px';
    progressBar.style.backgroundColor = '#333';
    progressBar.style.borderRadius = '3px';
    progressBar.style.overflow = 'hidden';
    progressBar.style.display = 'none'; 

    const progressFill = document.createElement('div');
    progressFill.style.width = '0%';
    progressFill.style.height = '100%';
    progressFill.style.backgroundColor = '#4CAF50';
    progressFill.style.transition = 'width 0.1s linear';
    
    progressBar.appendChild(progressFill);
    statusContainer.appendChild(statusLabel);
    statusContainer.appendChild(progressBar);
    
    container.appendChild(statusContainer);
    container.appendChild(canvas);

    // 4. Configuration for the Animation
    const duration = parseFloat(durationSec) || 4;
    const zoom = parseFloat(zoomFactor) || 1.15;
    const fps = 30;
    const durationMs = duration * 1000;

    let isRecording = !!(canvas.captureStream || canvas.mozCaptureStream);
    let recorder = null;
    let chunks = [];

    // Helper: Draw the current frame of the slow motion effect
    function renderFrame(progress) {
        // Apply an Ease In-Out algorithm to make the movement look beautifully smooth
        const t = progress;
        const easeProg = t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
        
        // Calculate dynamic zoom and subtle panning
        const currentZoom = 1.0 + ((zoom - 1.0) * easeProg);
        const panX = (width * -0.015) * easeProg; // subtle pan
        const panY = (height * 0.015) * easeProg; 

        // Draw Image onto transformed canvas
        ctx.fillStyle = '#000000';
        ctx.fillRect(0, 0, width, height);
        
        ctx.save();
        ctx.translate(width / 2 + panX, height / 2 + panY);
        ctx.scale(currentZoom, currentZoom);
        ctx.translate(-width / 2, -height / 2);
        
        // Use smooth image smoothing for scaling
        ctx.imageSmoothingEnabled = true;
        ctx.imageSmoothingQuality = 'high';
        
        ctx.drawImage(originalImg, 0, 0, width, height);
        ctx.restore();
    }

    // Attempt to set up video recording mechanism
    if (isRecording) {
        progressBar.style.display = 'block';
        try {
            const stream = (canvas.captureStream || canvas.mozCaptureStream).call(canvas, fps);
            
            // Choose the best available video codec combinations
            let mimeType = 'video/webm;codecs=vp9';
            let options = { mimeType };
            if (!MediaRecorder.isTypeSupported(options.mimeType)) {
                options.mimeType = 'video/webm;codecs=vp8';
                if (!MediaRecorder.isTypeSupported(options.mimeType)) {
                    options.mimeType = 'video/webm';
                    if (!MediaRecorder.isTypeSupported(options.mimeType)) {
                        options.mimeType = 'video/mp4'; 
                        if (!MediaRecorder.isTypeSupported(options.mimeType)) {
                            options = {}; // Give up and fall back to browser default
                        }
                    }
                }
            }

            recorder = new MediaRecorder(stream, options);
            
            recorder.ondataavailable = e => {
                if (e.data && e.data.size > 0) {
                    chunks.push(e.data);
                }
            };
            
            recorder.onstop = () => {
                const finalMime = recorder.mimeType || 'video/webm';
                const blob = new Blob(chunks, { type: finalMime });
                const videoUrl = URL.createObjectURL(blob);
                
                const video = document.createElement('video');
                video.controls = true;
                video.autoplay = true;
                video.loop = true;
                video.style.maxWidth = '100%';
                video.style.maxHeight = '60vh';
                video.style.border = '1px solid #333';
                video.style.borderRadius = '4px';
                video.src = videoUrl;

                // Replace preview canvas with the final playable video
                container.replaceChild(video, canvas);
                progressBar.style.display = 'none';

                // Add Download Button
                const btn = document.createElement('a');
                btn.href = videoUrl;
                btn.download = `slow-motion-${Date.now()}.${finalMime.includes('mp4') ? 'mp4' : 'webm'}`;
                btn.textContent = "Download Video";
                btn.style.textDecoration = 'none';
                btn.style.padding = '8px 16px';
                btn.style.backgroundColor = '#4CAF50';
                btn.style.color = '#fff';
                btn.style.borderRadius = '4px';
                btn.style.fontWeight = 'bold';
                btn.style.marginTop = '8px';
                btn.style.cursor = 'pointer';
                btn.style.transition = 'background-color 0.2s';
                btn.onmouseover = () => btn.style.backgroundColor = '#45a049';
                btn.onmouseout = () => btn.style.backgroundColor = '#4CAF50';
                
                statusContainer.replaceChild(btn, statusLabel);
            };
            
            setTimeout(() => {
                recorder.start();
                requestAnimationFrame(animationLoop);
            }, 100);
            
        } catch (err) {
            isRecording = false;
            progressBar.style.display = 'none';
            statusLabel.textContent = "Previewing Slow Motion Effect (Video export unsupported on your browser)";
            requestAnimationFrame(animationLoop);
        }
    } else {
        statusLabel.textContent = "Previewing Slow Motion Effect (Video export unsupported on your browser)";
        requestAnimationFrame(animationLoop);
    }

    let startTime = null;

    // Core application loop
    function animationLoop(timestamp) {
        if (!startTime) startTime = timestamp;
        let elapsed = timestamp - startTime;

        if (isRecording) {
            let progress = Math.min(elapsed / durationMs, 1.0);
            progressFill.style.width = `${progress * 100}%`;
            
            renderFrame(progress);

            if (elapsed >= durationMs) {
                // Ensure Final frame is flushed to the video track
                renderFrame(1.0);
                recorder.stop();
                return;
            }
        } else {
            // Infinite looping ping-pong preview if recording is completely unsupported
            let cycle = Math.floor(elapsed / durationMs);
            let p = (elapsed % durationMs) / durationMs;
            let progress = (cycle % 2 === 0) ? p : 1 - p;
            renderFrame(progress);
        }

        requestAnimationFrame(animationLoop);
    }

    // Force draw initial 0% frame so the canvas isn't visibly blank while launching
    renderFrame(0);

    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 converts still images into slow-motion videos by applying smooth zoom and panning effects. It uses an ease-in-out animation algorithm to create professional-looking motion from a static photo, allowing users to export the result as a video file. This is ideal for creating cinematic social media content, enhancing digital presentations, or adding subtle movement to still photography for more engaging storytelling.

Leave a Reply

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