TToolbox
✂️

Image Cropper

Crop and resize images

About this tool

Interactive image cropping and aspect ratio transformation is essential for responsive web layouts, social media avatar uploads, e-commerce catalog photography, and ad banner composition. Incorrect dimensions trigger browser stretching, distortion, and poor focal framing. This tool provides client-side HTML5 Canvas marquee cropping with lockable aspect ratios (1:1, 16:9, 4:3, 9:16), pixel-perfect coordinate scaling, and lossless PNG/WebP exports directly in your browser.

How to Use This Tool (Step-by-Step)

1

Upload Image

Upload your photo (JPG, PNG, WebP) into the workspace. Image loads instantaneously into local memory.

2

Adjust Crop Box & Ratio

Lock a standard aspect ratio (1:1 avatar or 16:9 banner) and drag corner handles to frame the subject.

3

Preview Crop & Download

Review the cropped composition in the real-time preview panel. Download the crisp cropped graphic with one click.

Locked Ratios & Freeform Modes

Toggles between freeform rectangle selection and locked presets: 1:1, 4:3, 16:9 widescreen, and 9:16 vertical shorts.

Lossless Canvas Pixel Slicing

Uses browser-native `drawImage` source-to-destination coordinate mapping, preserving original pixel clarity without blur.

100% Client-Side Air-Gapped

All image slicing runs 100% inside local device memory. Private family photography and ID cards are never uploaded.

Image Composition Principles & Cropping Tips

  • •Leave breathing margins for avatars: Tight avatar crops get scalped when circular masks are applied. Maintain a 15% outer margin.
  • •Re-center focal subjects on horizontal-to-vertical crops: Cropping 16:9 to 9:16 discards vast lateral areas; re-align subjects centrally.
  • •Format selection rule: Export photos as JPEG/WebP for minimal file weights; export transparent graphics as PNG to preserve alpha channels.

Code & Transformation Examples

Social Media Image Cropping Standards Benchmark

Platform Module
• 微信 / GitHub / 社交头像 : 1:1 正方形 (推荐 400 × 400)
• 微信公众号文章封面次图   : 1:1 正方形 (推荐 200 × 200)
• 微信公众号文章顶部首图   : 2.35:1 超宽屏 (推荐 900 × 383)
• B站 / YouTube 视频封面   : 16:9 宽屏 (推荐 1280 × 720 / 1080P)
• 小红书 / 抖音短视频竖封面 : 3:4 或 9:16 竖屏 (推荐 1080 × 1920)
Composition Tip
采用经典“三分法则(Rule of Thirds)”,将人物双眼或主体轮廓放置在九宫格的四个交叉点上,视觉平衡感最强。

* Pre-cropping to platform-specific aspect ratios prevents jarring automatic stretching by social media apps.

HTML5 Canvas Coordinate Cropping Snippet

Canvas drawImage Snippet
function cropImage(img, cropX, cropY, cropW, cropH) {
  const canvas = document.createElement('canvas');
  canvas.width = cropW;
  canvas.height = cropH;
  const ctx = canvas.getContext('2d');
  // 9参数: img, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight
  ctx.drawImage(img, cropX, cropY, cropW, cropH, 0, 0, cropW, cropH);
  return canvas.toDataURL('image/png');
}
Benefit
通过设置目标尺寸等于裁剪框尺寸(canvas.width = cropW),可实现原图 1:1 物理像素完美无损截取!

* Native canvas slicing processes 4K high-resolution photos in milliseconds with zero dependencies.

Frequently Asked Questions

Q: Why is the cropped image sometimes larger in file size than the original?

A: Exporting a heavily compressed JPEG into lossless PNG inflates byte counts. Select JPEG or WebP for continuous-tone photographs.

Q: Does this tool support cropping after image rotation?

A: Yes. Rotate your image by 90° or flip axes to correct orientation before dragging marquee handles to frame the crop.

Q: Will multi-megapixel DSLR raw exports crash the browser?

A: The viewer applies responsive downsampling for smooth handle dragging while mapping back to full physical resolution during final export.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/