Please bookmark this page to avoid losing your image tool!

Image Heart Shape 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) {
    const canvas = document.createElement('canvas');
    const w = originalImg.naturalWidth;
    const h = originalImg.naturalHeight;
    canvas.width = w;
    canvas.height = h;
    const ctx = canvas.getContext('2d');

    // Define the heart shape path.
    // These coordinates are based on a known SVG path for a heart,
    // and we will scale them to fit the image dimensions.
    // The original path is defined within a bounding box approximately
    // from (20, 25) to (130, 120).
    const originalBox = {
        x: 20,
        y: 25,
        w: 110,
        h: 95
    };

    const scaleX = w / originalBox.w;
    const scaleY = h / originalBox.h;

    // Helper functions to scale the coordinates
    const transformX = (x) => (x - originalBox.x) * scaleX;
    const transformY = (y) => (y - originalBox.y) * scaleY;

    ctx.beginPath();
    ctx.moveTo(transformX(75), transformY(40));
    ctx.bezierCurveTo(transformX(75), transformY(37), transformX(70), transformY(25), transformX(50), transformY(25));
    ctx.bezierCurveTo(transformX(20), transformY(25), transformX(20), transformY(62.5), transformX(20), transformY(62.5));
    ctx.bezierCurveTo(transformX(20), transformY(80), transformX(40), transformY(102), transformX(75), transformY(120));
    ctx.bezierCurveTo(transformX(110), transformY(102), transformX(130), transformY(80), transformX(130), transformY(62.5));
    ctx.bezierCurveTo(transformX(130), transformY(62.5), transformX(130), transformY(25), transformX(100), transformY(25));
    ctx.bezierCurveTo(transformX(85), transformY(25), transformX(75), transformY(37), transformX(75), transformY(40));
    ctx.closePath();

    // Use the path as a clipping mask
    ctx.clip();

    // Draw the image inside the clipped region
    ctx.drawImage(originalImg, 0, 0, w, h);

    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 Heart Shape Creator allows users to transform their images into heart-shaped cutouts. This tool is useful for creating romantic or themed visuals for social media, invitations, or personal projects. Simply upload an image, and the tool will crop it into a heart shape, enhancing its aesthetic appeal. It is ideal for occasions such as Valentine’s Day, anniversaries, or any event where a heart motif is desired.

Leave a Reply

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