You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用ImageResizer v4实现图片自适应裁剪/补白至1920×335px?

Solution for ImageResizer v4 Target Size Handling (1920x335)

Hey there! Let's solve this image resizing requirement perfectly with ImageResizer v4. The key is combining specific parameters to cover all three scenarios you mentioned—here's the exact setup you need:

Core Parameter String

?w=1920&h=335&mode=crop&scale=canvas&anchor=center&bgcolor=ffffff

Let's break down how this works for each case:

1. Image is larger than 1920x335 (or has a mismatched larger aspect ratio)

  • The mode=crop parameter takes priority here: ImageResizer will first crop the image to match the target aspect ratio (1920:335), then resize the cropped result to exactly 1920x335. This avoids wasting pixels and ensures the output fits your dimensions perfectly without unnecessary scaling.

2. Image is smaller than 1920x335

  • scale=canvas kicks in here instead of scaling up the image itself. It keeps the original image size intact, then adds padding (specified by bgcolor) around it to expand the canvas to 1920x335. The anchor=center parameter ensures the original image stays centered in the padded canvas (you can adjust this to top, bottom, left, right, etc., if needed).

3. Image is between sizes (e.g., width fits but height is too short, or vice versa)

  • ImageResizer will first proportionally shrink the image to fit within the 1920x335 bounds (no upscaling, so no blurriness), then use scale=canvas to add padding to fill the remaining space. This balances resizing and padding exactly as you requested.

Optional Adjustments

  • For a transparent background instead of white, replace bgcolor=ffffff with bgcolor=transparent.
  • Tweak the anchor value to change where the original image sits in the padded canvas (e.g., anchor=top for top-aligned images with bottom padding).
  • Add format=webp or format=avif to optimize the output image format for web use.

内容的提问来源于stack exchange,提问作者Oliver

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:28:32