Help us understand the problem. What is going on with this article?

ImageMagickなのに左にも上にもappendできる!

More than 5 years have passed since last update.

@chocomelon: なんでImageMagickって左と上にappendできないの?死ぬの?

@t_cyrill: ファイルの引数逆にすればええやん

@chocomelon: めんどいやん。わかりづらいやん。

ってことで左にも上にもappendできるバッチ作った

こんなふうにしたいときに有効だよ!

flan.png
07_00_flandre.png

koakuma.png
08_00_koakuma.png

sanae.png
09_00_sanae.png

例1: フランちゃん起点にして左に数珠つなぎ

./append.sh -left flan.png koakuma.png sanae.png append1.png

append1.png
append.png

例2: フランちゃんを起点に上に数珠つなぎ

./append.sh -top flan.png koakuma.png sanae.png append2.png

append2.png
append.png

もちろん右にも下にもつなげるよ!(右と下はデフォルトのappendでできます)

使い方

appended.pngに出力したいを保存したい場合

./apend.sh -(left|right|top|bottom) file1.png file2.png ..... appendedfile.png

スクリプト本体

append.sh

#!/bin/bash                                                                                                                                           

if [ $# -lt 3 ]; then
    echo "Usage: append DIRECTION file1 file2 ... dest"
    echo "i.e.: append -left 01.png 02.png dest.png"
    echo "DIRECTION = [-left|-right|-top|-bottom]"
    exit
fi

DIRECTION=$1
shift;
ARGS=("$@")
DEST=${ARGS[((${#ARGS[@]}-1))]}

FILES="${ARGS[@]:0:((${#ARGS[@]}-1))}"

case "$DIRECTION" in
    "-left"|"-right") OPTIONS='+append';;
    "-top"|"-bottom") OPTIONS='-append';;
esac

case "$DIRECTION" in
    "-left"|"-top") FILES=`echo "$FILES" | awk '{for(i=NF;i>0;i--) printf("%s ",$i);}' | xargs`;;
esac

convert $OPTIONS $FILES $DEST

gistも貼っとくよ!

https://gist.github.com/chocomelonchan/3f5f6dde1a32e9e34d35

ちなみに…このスクリプトは @chocomelon があーだこーだ言ってたら隣に居た @t_cyrill がいい感じにして(作って)くれました。

chocomelon
Androidの投稿多め。難しいことはわかりません。 よくインターネットの人にディスられます_(:3」∠)_
https://twitter.com/__chocomelon
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした