Last active
April 28, 2019 09:30
-
-
Save hata6502/dc46fd6108301ed9106da67db6768ec9 to your computer and use it in GitHub Desktop.
指定の比率で画像をトリミングします。ImageMagick を使って 16:9 でトリミングするのが面倒だったのでシェルスクリプトにしました。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -lt 6 ]; then | |
echo "Usage: `basename $0` (source path) (width rate) (height rate) (X offset) (y offset) (destination path) [(options)]" | |
exit 1 | |
fi | |
width=`identify -format "%w" $1` | |
height=$((width*$3/$2)) | |
convert "$1" ${@:7} -crop ${width}x${height}+$4+$5 "$6" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
環境要件: ImageMagick が必要です。
使い方: trimrate (元ファイル) (幅比率) (高さ比率) (横オフセット) (縦オフセット) (保存先パス) [(追加の ImageMagick オプション)]
(例) trimrate src.jpg 16 9 0 0 dest.jpg -gravity center