From 227b48bd41f4ac234a720b0e698c8bd5293cbbdf Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Tue, 14 Feb 2012 15:41:40 +0100 Subject: [PATCH] change border to white not black and resize upfront and white borders --- lib/builder-utils.sh | 74 ++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/builder-utils.sh b/lib/builder-utils.sh index ff5ba5b..79d3723 100644 --- a/lib/builder-utils.sh +++ b/lib/builder-utils.sh @@ -134,9 +134,42 @@ convert_image() { local wight=`${CMD_identify} -format "%w" $src` ${CMD_identify} -format "%wx%h" $src + if [ $wight -lt $hight ] ; then + # Its higher so force x160 and let imagemagic decide the right wight + # then add transparency to the rest of the image to fit 160x160 + log_debug "Icon Wight: $wight < Hight: $hight" + convert $src -colorspace RGB -resize x160 \ + -size 160x160 xc:white +swap -gravity center -composite \ + -modulate 110 -colors 256 $OUTPUT_DIR/resize.png + builder_check_error "converting image" + elif [ $wight -gt $hight ] ; then + # Its wider so force 160x and let imagemagic decide the right hight + # then add transparency to the rest of the image to fit 160x160 + log_debug "Icon Wight: $wight > Hight: $hight" + convert $src -colorspace RGB -resize 160x \ + -size 160x160 xc:white +swap -gravity center -composite \ + -modulate 110 -colors 256 $OUTPUT_DIR/resize.png + builder_check_error "converting image" + elif [ $wight -eq $hight ] ; then + # Its scare so force 160x160 + log_debug "Icon Wight: $wight = Hight: $hight" + convert $src -colorspace RGB -resize 160x160 \ + -size 160x160 xc:white +swap -gravity center -composite \ + -modulate 110 -colors 256 $OUTPUT_DIR/resize.png + builder_check_error "converting image" + else + # Imagemagic is unable to detect the aspect ratio so just force 160x160 + # this could result in streched images + log_debug "Icon Wight: $wight unknown Hight: $hight" + convert $src -colorspace RGB -resize 160x160 \ + -size 160x160 xc:white +swap -gravity center -composite \ + -modulate 110 -colors 256 $OUTPUT_DIR/resize.png + builder_check_error "converting image" + fi + # create a diffence image from the source - convert $src \( +clone -fx 'p{0,0}' \) -compose Difference -composite \ - -modulate 100,0 +matte $OUTPUT_DIR/difference.png + convert $OUTPUT_DIR/resize.png \( +clone -fx 'p{0,0}' \) -compose Difference -composite \ + -modulate 100,0 +matte $OUTPUT_DIR/difference.png # remove the black, replace with transparency convert $OUTPUT_DIR/difference.png -bordercolor white -border 1x1 -matte \ @@ -152,41 +185,8 @@ convert_image() { $OUTPUT_DIR/matte-negated.png # you are going for: white interior, black exterior - composite -compose CopyOpacity $OUTPUT_DIR/matte-negated.png $src \ - $OUTPUT_DIR/final.png - - if [ $wight -lt $hight ] ; then - # Its higher so force x160 and let imagemagic decide the right wight - # then add transparency to the rest of the image to fit 160x160 - log_debug "Icon Wight: $wight < Hight: $hight" - convert $OUTPUT_DIR/final.png -colorspace RGB -resize x160 \ - -size 160x160 xc:transparent +swap -gravity center \ - -composite -modulate 110 -colors 256 png8:$dst - builder_check_error "converting image" - elif [ $wight -gt $hight ] ; then - # Its wider so force 160x and let imagemagic decide the right hight - # then add transparency to the rest of the image to fit 160x160 - log_debug "Icon Wight: $wight > Hight: $hight" - convert $OUTPUT_DIR/final.png -colorspace RGB -resize 160x \ - -size 160x160 xc:transparent +swap -gravity center \ - -composite -modulate 110 -colors 256 png8:$dst - builder_check_error "converting image" - elif [ $wight -eq $hight ] ; then - # Its scare so force 160x160 - log_debug "Icon Wight: $wight = Hight: $hight" - convert $OUTPUT_DIR/final.png -colorspace RGB -resize 160x160 \ - -size 160x160 xc:transparent +swap -gravity center \ - -composite -modulate 110 -colors 256 png8:$dst - builder_check_error "converting image" - else - # Imagemagic is unable to detect the aspect ratio so just force 160x160 - # this could result in streched images - log_debug "Icon Wight: $wight unknown Hight: $hight" - convert $OUTPUT_DIR/final.png -colorspace RGB -resize 160x160 \ - xc:transparent +swap -gravity center -composite \ - -modulate 110 -colors 256 png8:$dst - builder_check_error "converting image" - fi + composite -compose CopyOpacity $OUTPUT_DIR/matte-negated.png $OUTPUT_DIR/resize.png \ + $dst # New size # identify -format "%wx%h" $dst