#!/bin/bash
#torned paper
#gscrot-plugin


TEXTDOMAIN=gscrot-plugins-bash
TEXTDOMAINDIR=$GSCROT_INTL 
PLUGIN_NAME=$"torned paper"
PLUGIN_SORT=$"effect"
PLUGIN_TIP=$"generates a torned-border"
PLUGIN_EXT="png"

if [[ "${1}" = "name" ]];then
   	echo "${PLUGIN_NAME}"
    exit 0
elif [[ "${1}" = "sort" ]];then
    echo "${PLUGIN_SORT}"
    exit 0
elif [[ "${1}" = "tip" ]];then
    echo "${PLUGIN_TIP}"
    exit 0
elif [[ "${1}" = "ext" ]];then
    echo "${PLUGIN_EXT}"
    exit 0
elif [[ "${1}" = "lang" ]];then
    echo "shell"
    exit 0
fi

FILE="${1}"
#~ WIDTH="${2}"
#~ HEIGHT="${3}"
#FILEYTPE="${4}"
#GEO="${2}x${3}"

# Generate torned effect

convert "${FILE}" \( +clone -threshold -1 -virtual-pixel black \
-spread 10 -blur 0x3 -threshold 50% -spread 1 -blur 0x.7 \) \
+matte -compose Copy_Opacity -composite "${FILE}"


# Add hard shadow

convert "${FILE}" \( +clone -background black  -shadow 80x3+5+5 \) \
+swap -background none -mosaic +repage "${FILE}"

exit 0

 
