Disk applet v.1.00
[rmail.git] / scripts / cvt.sh
blobfae5e6218cf95f5a8d0aee09c37946c70c2dd3c3
1 #!/bin/sh
2 if [ -z "$1" ]; then
3 echo "$0 <filename>"
4 echo "The output is <filename>_thumb.png"
5 exit
6 fi
8 CONVERT="/home/roberto/RNF/ImageMagick/bin/convert"
10 #-- Source file without extension
11 SOURCE_NAME=`basename $1 | awk -F. -v OFS=. '{$NF=""; sub("[.]$", ""); print}'`
14 #-- Output Thumbnail
15 THUMB_OUT="${SOURCE_NAME}_final.png"
17 #-- Resized Thumbnail
18 THUMB_RESIZED="${SOURCE_NAME}_thumb_resized.png"
19 THUMB_SRC="${SOURCE_NAME}_thumb.png"
21 #-- Resized Thumbnail Mask
22 THUMB_MSK="${SOURCE_NAME}_thumb_msk.png"
24 #-- Resized Thumbnail Lighting Overlay
25 THUMB_OVR="${SOURCE_NAME}_thumb_ovr.png"
27 #-- Resize then crop off the parts of the image that overflows the desired size.
28 #$CONVERT $1 -thumbnail 100x100^ -gravity center -extent 100x100 ${THUMB_SRC}
29 #$CONVERT $1 -resize 100x100^ -gravity center -extent 100x100 ${THUMB_SRC}
30 #$CONVERT $1 -resize 48x48^ -gravity center -extent 48x48 ${THUMB_SRC}
31 $CONVERT $1 -resize 32x32^ -gravity center ${THUMB_RESIZED}
33 $CONVERT ${THUMB_RESIZED} -gravity center -extent 48x48 ${THUMB_SRC}
35 #-- For lets generate a rounded corners mask for our thumbnail image.
36 #$CONVERT ${THUMB_SRC} -alpha off -fill white -colorize 100% \
37 # -draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
38 # \( +clone -flip \) -compose Multiply -composite \
39 # \( +clone -flop \) -compose Multiply -composite \
40 # -background Gray50 -alpha Shape ${THUMB_MSK}
42 #-- For lets generate a rounded corners mask for our thumbnail image.
43 $CONVERT ${THUMB_SRC} -alpha off -fill white -colorize 100% \
44 -draw 'fill black polygon 0,0 0,7 7,0 fill white circle 7,7 7,0' \
45 \( +clone -flip \) -compose Multiply -composite \
46 \( +clone -flop \) -compose Multiply -composite \
47 -background Gray50 -alpha Shape ${THUMB_MSK}
49 #-- Now we have a 'shape mask' we want to use, I can apply the Aqua Effect
50 #-- effect to generate a lighting overlay, for this shape.
52 $CONVERT ${THUMB_MSK} -bordercolor None -border 1x1 \
53 -alpha Extract -blur 0x10 -shade 130x30 -alpha On \
54 -background gray50 -alpha background -auto-level \
55 -function polynomial 3.5,-5.05,2.05,0.3 \
56 \( +clone -alpha extract -blur 0x2 \) \
57 -channel RGB -compose multiply -composite \
58 +channel +compose -chop 1x1 ${THUMB_OVR}
60 #-- With a final light/shade overlay image such as the above we can easily
61 #-- apply it to any thumbnail image of the right size.
63 $CONVERT ${THUMB_SRC} ${THUMB_OVR} \( -clone 0,1 -compose Hardlight -composite \) \
64 -delete 0 -compose In -composite ${THUMB_OUT}
66 #-- Remove intermediate files
67 rm $THUMB_SRC
68 rm $THUMB_MSK
69 rm $THUMB_OVR