Last active
August 29, 2015 14:15
-
-
Save sakamoto-poteko/a1809d442beb4f52ccbd to your computer and use it in GitHub Desktop.
Async & Queued MgConvert
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 | |
src=$1 | |
des=$2 | |
width=$3 | |
height=$4 | |
watermark=$5 | |
if [ `identify -format "%n" ${src}` -eq 1 ] | |
then | |
convert ${src} -resize ${width}x${height} ${des} | |
elif [ `identify -format "%n" ${src}` -le 10 ] | |
then | |
convert ${src} -coalesce gif:- | convert gif:- -resize ${width}x${height} ${des} | |
else | |
convert ${src}[0] -resize ${width}x${height} ${des} | |
convert -background green -size 30x20 -gravity center -fill white -font helvetica -pointsize 12 label:GIF gif:- | composite -gravity NorthEast gif:- ${des} ${des} | |
fi | |
if [ ${width} -le 300 ] | |
then exit | |
fi | |
if [ `identify -format "%n" ${src}` -eq 1 ] | |
then | |
composite -gravity SouthEast -dissolve 50 ${watermark} ${des} ${des} | |
elif [ `identify -format "%n" ${src}` -le 10 ] | |
then | |
convert ${des} -gravity SouthEast -geometry +0+0 null: ${watermark} -compose dissolve -define compose:args=50 -layers composite -layers optimize ${des}; | |
else | |
composite -gravity SouthEast -dissolve 50 ${watermark} ${des} ${des} | |
fi | |
exit | |
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 | |
# Don't know if it is sync or async in MW call | |
# Will make it async anyway | |
nohup $PWD/convert.sh $1 $2 $3 $4 $5 >/dev/null 2>&1 & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment