Please bookmark this page to avoid losing your image tool!

Image Center 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.
function processImage(originalImg) {
  const canvas = document.createElement('canvas');
  const ctx = canvas.getContext('2d');

  const originalWidth = originalImg.width;
  const originalHeight = originalImg.height;

  let cropSize = Math.min(originalWidth, originalHeight);
  let sx = 0;
  let sy = 0;

  if (originalWidth > originalHeight) {
    // Image is wider than it is tall, crop the sides
    sx = (originalWidth - originalHeight) / 2;
    cropSize = originalHeight;
  } else if (originalHeight > originalWidth) {
    // Image is taller than it is wide, crop the top and bottom
    sy = (originalHeight - originalWidth) / 2;
    cropSize = originalWidth;
  }
  // If width and height are equal, cropSize is already correct and sx, sy are 0

  canvas.width = cropSize;
  canvas.height = cropSize;

  // Draw the cropped image onto the canvas
  // Parameters for drawImage:
  // image: The image to draw.
  // sx: The x-coordinate of the top-left corner of the sub-rectangle of the source image to draw.
  // sy: The y-coordinate of the top-left corner of the sub-rectangle of the source image to draw.
  // sWidth: The width of the sub-rectangle of the source image to draw.
  // sHeight: The height of the sub-rectangle of the source image to draw.
  // dx: The x-coordinate on the destination canvas at which to place the top-left corner of the source image.
  // dy: The y-coordinate on the destination canvas at which to place the top-left corner of the source image.
  // dWidth: The width to draw the image in the destination canvas.
  // dHeight: The height to draw the image in the destination canvas.
  ctx.drawImage(originalImg, sx, sy, cropSize, cropSize, 0, 0, cropSize, cropSize);

  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 Center Cropper is a tool that allows users to crop images to a square format by focusing on the center of the original image. It automatically determines the appropriate cropping area based on the image’s dimensions, ensuring that either the sides or the top and bottom are cropped evenly to create a balanced square output. This utility is useful for preparing images for social media profiles, avatars, product images, or any scenarios where a square aspect ratio is preferred.

Leave a Reply

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

Other Image Tools:

Image Petzval Lens Swirly Bokeh Effect Creator

Image Mimiya 645 Medium Format Filter Effect Tool

Photo Fujifilm Klasse W Filter Effect Application

Image Deardorff Large Format Filter Effect Application

Image Lomo LC-A Filter Effect Tool

Image Large Format Filter Effect Application

Image Zone Plate Lens Effect Creator

Photo Kodak Retina Filter Effect Tool

Image Polaroid 600 Filter Effect Tool

Photo Black and White Yellow Filter Effect Tool

Image Contax G2 Film Camera Render Effect Applicator

Image 110 Film Format Filter Effect Tool

Photo Jupiter-9 Portrait Lens Filter Effect

Image Fujifilm GW690 Texas Leica Filter Effect Application

Image Zeiss T* Coating Filter Effect Tool

Image Hoya R72 Infrared Filter Effect Tool

Image Filter Effect for Zeiss Ikon Contaflex

Photo Olympus Mju-II/Stylus Epic Filter Effect Tool

Image NiSi Nano IR ND Filter Effect Tool

Image Polaroid SX-70 Filter Effect Tool

Image Linhof Technika Filter Effect Tool

Image Lee Big Stopper 10-Stop ND Filter Effect Tool

Image Minolta X-700 Film Camera Render Effect Creator

Image ORWO UN54 Motion Picture Film Effect Applicator

Image Shen-Hao Large Format Filter Effect Tool

Image Impossible Project Polaroid Filter Effect Tool

Photo Foma Retropan 320 Film Filter Effect Tool

Image Fuji QuickSnap Disposable Filter Effect Application

Image 220 Film Format Filter Effect

Image Black and White with Green #61 Filter Effect Tool

Image 35mm Panoramic Camera Filter Effect Tool

Image Hitech Firecrest ND Filter Effect Formatter

Photo Rodenstock Digital Vario ND Filter Effect Tool

Image Leica Yellow Filter Effect Application

Image Argus C3 Vintage Camera Filter Effect

Image ORWO NP22 Film Filter Effect Application

See All →