
有許多相同尺寸的圖像。有沒有辦法將它們全部裁剪到相同的座標?
Windows 7的。
答案1
你可以使用 imagemagick 來做到這一點。以下是一些產品範例手動的:
convert rose: rose.gif
convert rose: -crop 40x30+10+10 crop.gif
convert rose: -crop 40x30+40+30 crop_br.gif
convert rose: -crop 40x30-10-10 crop_tl.gif
convert rose: -crop 90x60-10-10 crop_all.gif
convert rose: -crop 40x30+90+60 crop_miss.gif
一個範例循環可以對所有圖像執行它。就像是:
for i in `ls in\`
do
convert $i -crop 40x30+10+10 out/`basename $i`
done
上面我假設 in 檔案位於目錄 in/ 中,out 檔案會儲存在目錄 out/ 中
答案2
由於您使用的是 Windows,因此請下載ImageMagick 的便攜式或安裝程式 Windows 二進位版本,然後在包含圖像的目錄中執行以下命令(自然地使用轉換程式在你的路徑某處):
for %f in (*.jpg) do convert -crop 32x32+16+16 "%~f" "cropped_%~f"
就這樣,簡單得就像餡餅一樣。不需要“UNIX-y shell”或“超過四十行程式碼”建議由一些人。