summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schwager <[email protected]>2012-01-29 15:58:12 (GMT)
committer Daniel Schwager <[email protected]>2012-01-29 15:58:12 (GMT)
commit976d2a3ec93e5b384b9b1a8d29c76ebf750ce7f9 (patch)
treebaaeae576220f52381c9e00e10ffe23016079307
parent441fdd95aa33ca63d342b908e5478c4358f9c13b (diff)
- moved image converting to builder-utils.h
- added logging functionality - setup inside opsi-builder.cfg by "DEBUG_LEVEL"
-rw-r--r--conf/opsi-builder.cfg4
-rw-r--r--lib/builder-targets.sh38
-rw-r--r--lib/builder-utils.sh55
3 files changed, 60 insertions, 37 deletions
diff --git a/conf/opsi-builder.cfg b/conf/opsi-builder.cfg
index 1eda030..ac9928d 100644
--- a/conf/opsi-builder.cfg
+++ b/conf/opsi-builder.cfg
@@ -9,6 +9,10 @@
#################################
TMP_DIR=/tmp
+# Setup debug level, be more verbose
+# Valid values: debug, <empty>
+DEBUG_LEVEL=
+
# STATUS - defines the stabability of the build
# Valid values:
# integration: this is used by a continuous integration server.
diff --git a/lib/builder-targets.sh b/lib/builder-targets.sh
index 1d9b496..9d6bc2d 100644
--- a/lib/builder-targets.sh
+++ b/lib/builder-targets.sh
@@ -148,44 +148,8 @@ builder_create() {
# converting icon file
local iconfile_src=${DIST_FILE[$ICON_FILE_INDEX]}
ICONFILE=$OUTPUT_DIR/$PN.png
- HIGHT=`identify -format "%h" $iconfile_src`
- WIGHT=`identify -format "%w" $iconfile_src`
- identify -format "%wx%h" $iconfile_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
- echo "Icon Wight: $WIGHT < Hight: $HIGHT"
- convert $iconfile_src -transparent white -background transparent -resize x160 \
- -size 160x160 xc:transparent +swap -gravity center -composite $ICONFILE
- 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
- echo "Icon Wight: $WIGHT > Hight: $HIGHT"
- convert $iconfile_src -transparent white -background transparent -resize 160x \
- -size 160x160 xc:transparent +swap -gravity center -composite $ICONFILE
- builder_check_error "converting image"
- elif [ $WIGHT -eq $HIGHT ] ; then
- # Its scare so force 160x160
- echo "Icon Wight: $WIGHT = Hight: $HIGHT"
- convert $iconfile_src -transparent white -background transparent -resize 160x160 \
- -size 160x160 xc:transparent +swap -gravity center -composite $ICONFILE
- builder_check_error "converting image"
- else
- # Imagemagic is unable to detect the aspect ratio so just force 160x160
- # this could result in streched images
- #echo "Icon Wight: $WIGHT Hight: $HIGHT"
- convert $iconfile_src -transparent white -background transparent -resize 160x160 \
- xc:transparent +swap -gravity center -composite $ICONFILE
- builder_check_error "converting image"
- fi
- identify -format "%wx%h" $ICONFILE
- HIGHT=`identify -format "%h" $ICONFILE`
- WIGHT=`identify -format "%w" $ICONFILE`
- echo "Opsi Icon Wight: $WIGHT Hight: $HIGHT"
+ convert_image $iconfile_src $ICONFILE
cp -a $ICONFILE $INST_DIR/CLIENT_DATA
-
# copy binaries
for (( i = 0 ; i < ${#SOURCE[@]} ; i++ )) ; do
diff --git a/lib/builder-utils.sh b/lib/builder-utils.sh
index b29afae..b7d5477 100644
--- a/lib/builder-utils.sh
+++ b/lib/builder-utils.sh
@@ -77,3 +77,58 @@ builder_check_error() {
fi
}
+log_debug() {
+ local str=$1
+
+ if [ "$DEBUG_LEVEL" = "debug" ] || [ "$DEBUG_LEVEL" = "info" ] ; then
+ echo $str
+ fi
+}
+
+###################
+# Convert image
+###################
+convert_image() {
+ local src=$1
+ local dst=$2
+
+ local hight=`identify -format "%h" $src`
+ local wight=`identify -format "%w" $src`
+ 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 -transparent white -background transparent -resize x160 \
+ -size 160x160 xc:transparent +swap -gravity center -composite $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 $src -transparent white -background transparent -resize 160x \
+ -size 160x160 xc:transparent +swap -gravity center -composite $dst
+ builder_check_error "converting image"
+ elif [ $wight -eq $hight ] ; then
+ # Its scare so force 160x160
+ log_debug "Icon Wight: $wight = Hight: $hight"
+ convert $src -transparent white -background transparent -resize 160x160 \
+ -size 160x160 xc:transparent +swap -gravity center -composite $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 Hight: $hight"
+ convert $src -transparent white -background transparent -resize 160x160 \
+ xc:transparent +swap -gravity center -composite $dst
+ builder_check_error "converting image"
+ fi
+
+ # New size
+ # identify -format "%wx%h" $dst
+ hight=`identify -format "%h" $dst`
+ wight=`identify -format "%w" $dst`
+ log_debug "Opsi Icon Wight: $wight Hight: $hight"
+
+} \ No newline at end of file

Powered by Domaintechnik.at | Hosting - Domain - Webspace