Skip to content

Instantly share code, notes, and snippets.

@smison
Last active July 10, 2016 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smison/cf51929f332aeac9609457ae1c6aa7e9 to your computer and use it in GitHub Desktop.
Save smison/cf51929f332aeac9609457ae1c6aa7e9 to your computer and use it in GitHub Desktop.
原稿を投稿サイズにトリミング&リサイズ
#! /bin/bash
# このスクリプトの場所にcd
cd `dirname $0`
# ファイル名
filename=4koma.png
# 内枠周辺だけを切出す
offset_x=100
offset_y=100
canvas_width=4299
canvas_height=6071
inner_width=2953
inner_height=4252
start_x=`expr \( $canvas_width - $inner_width \) / 2 - $offset_x`
start_y=`expr \( $canvas_height - $inner_height \) / 2 - $offset_y`
crop_width=`expr $inner_width + $offset_x \* 2`
crop_height=`expr $inner_height + $offset_y \* 2`
convert ${filename} -crop ${crop_width}x${crop_height}+${start_x}+${start_y} inner.png
# 4コマ部分を切出す
offset_x=100
offset_y=100
canvas_width=4299
canvas_height=6071
inner_width=2953
inner_height=4252
start_x=`expr \( $canvas_width - $inner_width \) / 2 - $offset_x`
start_y=`expr \( $canvas_height - $inner_height \) / 2 - $offset_y`
crop_width=`expr $inner_width / 2 + $offset_x`
crop_height=`expr $inner_height + $offset_y \* 2`
convert ${filename} -crop ${crop_width}x${crop_height}+${start_x}+${start_y} left.png
start_x=`expr $start_x + $crop_width`
convert ${filename} -crop ${crop_width}x${crop_height}+${start_x}+${start_y} right.png
# 縮小する
convert -resize x900 inner.png inner_resized.png
convert -resize x900 left.png left_resized.png
convert -resize x900 right.png right_resized.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment