Please bookmark this page to avoid losing your image tool!

Image Classic Heart Shape Cropper

(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) {
    // Create a new canvas element to draw on.
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Get the dimensions from the original image.
    const w = originalImg.naturalWidth || originalImg.width;
    const h = originalImg.naturalHeight || originalImg.height;

    // Set the canvas size to match the image size.
    canvas.width = w;
    canvas.height = h;

    // --- Create the heart-shaped clipping path ---
    // The path is created using two symmetrical cubic Bézier curves,
    // which allows for a smooth and classic heart shape.
    ctx.beginPath();

    // Start drawing from the bottom tip of the heart.
    ctx.moveTo(w / 2, h);

    // Draw the left side of the heart.
    // The control points are carefully selected to form the curve of the left lobe.
    ctx.bezierCurveTo(
        w * 0.1, h * 0.8, // Control point 1 (pulls the curve to the lower-left)
        0, h * 0.45,      // Control point 2 (pulls the curve to the upper-left, forming the lobe)
        w / 2, h * 0.25   // End point (the cleft at the top center of the heart)
    );

    // Draw the right side of the heart, mirroring the left side.
    ctx.bezierCurveTo(
        w, h * 0.45,      // Control point 1 (mirrors the left side's control point 2)
        w * 0.9, h * 0.8, // Control point 2 (mirrors the left side's control point 1)
        w / 2, h          // End point (back where we started, at the bottom tip)
    );

    ctx.closePath();

    // Set the current path as a clipping region.
    // All subsequent drawing operations will be masked by this shape.
    ctx.clip();

    // Draw the original image onto the canvas.
    // Due to the clipping, only the part of the image inside the heart shape will be visible.
    ctx.drawImage(originalImg, 0, 0, w, h);

    // Return the canvas element, which now contains the heart-shaped image.
    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 Classic Heart Shape Cropper is a tool designed to crop images into a classic heart shape. It allows users to upload their images and automatically crops them to create a visually appealing heart-shaped design. This tool can be useful for creating personalized gifts, decorations for events like Valentine’s Day, or unique social media posts. It provides an easy way to add a romantic or artistic touch to images for various purposes.

Leave a Reply

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