Bash script for picon creation (only for linux users)

helour

Registered
Messages
9
I've wrote very simple bash script for picon (with small rounded corners) creating. You have to need install pngquant and imagemagick before script running.

PHP:
#!/bin/sh
#

##############################################################
#
# Input arguments:
# $1 - width of the output picon image
# $2 - height of the output picon image
# $3 - background color
# $4 - input logo file
# $5 - output picon file
#
# Example of use:
# create_picon.sh 100 60 black logo.png picon.png
#
##############################################################

width=$1
height=$2

width_1=$((${width} - 1))
height_1=$((${height} - 1))

scale=90 # scale in percentage
s_width=$((${width} * $scale / 100))
s_height=$((${height} * $scale / 100))

if [ "$#" -ne 5 ]; then
    echo "Usage: `basename $0` weight height (black|white) input_file output_file"
    exit 1
fi

TMP1=`mktemp XXXXXXXX.png`

convert $4 -adaptive-resize ${s_width}x${s_height} -background None -gravity center -extent ${width}x${height} $TMP1
convert \( -size ${width}x${height} canvas:$3 -raise 1 -normalize -blur 0x5 \) $TMP1 -composite $TMP1
convert $TMP1 -alpha set \( +clone -alpha transparent -background none -fill white -stroke none -strokewidth 0 -draw 'roundrectangle 0,0 '$width_1','$height_1' 5,5' \) -compose DstIn -composite $TMP1

pngquant $TMP1
mv ${TMP1%.*}-fs8.png $5

rm -f $TMP1
rm -f ${TMP1%.*}-fs8.png
 
Top