Please bookmark this page to avoid losing your image tool!

Image Translation Customizer

(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.
/**
 * Translates (moves) an image within its frame by a specified number of pixels.
 *
 * @param {HTMLImageElement} originalImg The original image object to process.
 * @param {number} [translateX=0] The number of pixels to move the image horizontally. Positive values move it right, negative values move it left.
 * @param {number} [translateY=0] The number of pixels to move the image vertically. Positive values move it down, negative values move it up.
 * @returns {HTMLCanvasElement} A new canvas element containing the translated image.
 */
function processImage(originalImg, translateX = 0, translateY = 0) {
  // Create a new canvas element
  const canvas = document.createElement('canvas');

  // Use naturalWidth/Height for the intrinsic size, falling back to width/height
  const w = originalImg.naturalWidth || originalImg.width;
  const h = originalImg.naturalHeight || originalImg.height;

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

  // Get the 2D rendering context
  const ctx = canvas.getContext('2d');

  // Draw the original image onto the canvas at the new, translated coordinates.
  // The parts of the image that are moved outside the canvas bounds will be clipped.
  // The areas of the canvas where the image isn't drawn will be transparent by default.
  ctx.drawImage(originalImg, translateX, translateY);

  // Return the canvas with the translated 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 Translation Customizer is a tool that allows users to adjust the positioning of an image within its frame by translating it horizontally and vertically. This can be particularly useful for graphic design, photo editing, and web development, where precise image placement is essential. Users can easily move images by a specified number of pixels in either direction, making it ideal for creating layouts, aligning elements, or repositioning images within a composition.

Leave a Reply

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