summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2005-07-19 15:09:05 +0000
committerAndreas Brachold <vdr07@deltab.de>2005-07-19 15:09:05 +0000
commitf897f2aa7055c493db6391c50c8d19da970078e8 (patch)
treed13a515b24c149d7da4e9828cc9e9c73d4916f00 /scripts
downloadvdr-plugin-image-f897f2aa7055c493db6391c50c8d19da970078e8.tar.gz
vdr-plugin-image-f897f2aa7055c493db6391c50c8d19da970078e8.tar.bz2
Initial import with release 0.2.3
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/imageplugin.sh160
-rwxr-xr-xscripts/mount.sh35
2 files changed, 195 insertions, 0 deletions
diff --git a/scripts/imageplugin.sh b/scripts/imageplugin.sh
new file mode 100755
index 0000000..2afd734
--- /dev/null
+++ b/scripts/imageplugin.sh
@@ -0,0 +1,160 @@
+#!/bin/bash
+# script for vdr-imageplugin to convert the selected image to pnm-image
+# needs : netpbm-progs > anytopnm pnmscale pnmfile pnmcut pnmflip
+#
+# History:
+# 2004-08-12 Initalrelease, Andreas Brachold <vdr04-at-deltab.de>
+# base on prior work for convert.sh
+# by Onno Kreuzinger <o.kreuzinger-at-kreuzinger.biz>
+# Andreas Holzhammer and <Interpohl-at-vdr-portal.de>
+#
+################################################################################
+# Userconfig:
+################################################################################
+# if your install external software like netpbm outside /bin:/usr/bin, adjust folder
+PATH=/usr/local/bin:$PATH
+# Set to "yes" to speedup reviewed image
+TMPCACHE=no
+# Set to "no" if this script work and your don't need success messages
+VERBOSE=yes
+# Set to "yes" if this script don't work, only usable if your self execute the script from shell
+DEBUG=no
+
+################################################################################
+# and now the script
+################################################################################
+[ "z$DEBUG" = "zyes" ] && set -xv
+SCRIPTNAME=$(basename "$0")
+{
+[ "z$VERBOSE" = "zyes" ] && echo "called '$SCRIPTNAME $*'"
+
+if [ $# -lt 7 ] ; then
+ echo "Usage: $SCRIPTNAME infile outfile WIDTH HEIGHT ZOOMFACTOR LEFTPOS TOPPOS [FLIPCMD]" 1>&2
+ echo " e.g.: $SCRIPTNAME in.png out.pnm 720 576 0 0 0" 1>&2
+ echo " or .: $SCRIPTNAME in.png out.pnm 720 576 3 360 360 left" 1>&2
+ echo "" 1>&2
+ echo "WIDTH - Width of TVScreen (720)" 1>&2
+ echo "HEIGHT - Height of TVScreen (480..576)" 1>&2
+ echo "ZOOMFACTOR - Zoomfactor (0....10)" 1>&2
+ echo "LEFTPOS - Offset from left on Zoommode (0......)" 1>&2
+ echo "TOPPOS - Offset from top on Zoommode (0......)" 1>&2
+ echo "FLIPCMD - optional should image flip (left,right,original)" 1>&2
+ exit 1
+fi
+
+ # Defaultvalue, overwrite with env from plugin
+ ASPECT_RATIO="${ASPECT_RATIO:-"4:3"}"
+
+ # check requirement external programs
+ REQUIREMENTS="anytopnm pnmscale pnmfile pnmcut pnmflip"
+ for i in $REQUIREMENTS
+ do
+ type "$i" > /dev/null 2>&1
+ [ $? -ne 0 ] && echo -e "$SCRIPTNAME: Error ! External required program: \"$i\" not found !\n Please adjust PATH or install it inside follow Folder \"$PATH\" \n" && exit 1
+ done
+
+ INFILE="$1"
+ OUTFILE="$2"
+ OUT_DISPLAY_X=$3
+ OUT_DISPLAY_Y=$4
+ ZOOMFACTOR=$5
+ LEFTPOS=$6
+ TOPPOS=$7
+ FLIPCMD="$8"
+
+ OUTDIR=$(dirname "$OUTFILE")
+ [ ! -d "$OUTDIR" ] && mkdir -p "$OUTDIR"
+
+ TMPFILE="$OUTFILE.tmp"
+ PARFILE="$OUTFILE.par"
+
+ # remove precreated files if called with flip "left","right" or "original"
+ [ -s "$OUTFILE" -a "$FLIPCMD" != "" ] && rm -f "$OUTFILE"
+ [ -s "$TMPFILE" -a "$FLIPCMD" != "" ] && rm -f "$TMPFILE"
+
+ if [ -s "$OUTFILE" ] ; then
+ [ "z$VERBOSE" = "zyes" ] && echo "Success! Convert not required, $OUTFILE exists already!"
+ exit 0
+ else
+
+ # Convert Image to PNM File
+ [ ! -s "$TMPFILE" ] && anytopnm "$INFILE" > "$TMPFILE"
+ # if success
+ if [ -s "$TMPFILE" ] ; then
+
+ # Get image resolution
+ RES=`echo $( pnmfile < "$TMPFILE" -)` # checked with netpbm 10.0,
+ # Parse pnmfile output "-: PPM raw, 768 by 576 maxval 255" => 768 x 576
+ X_RES=$(echo -e "$RES"| cut -d " " -f 4)
+ Y_RES=$(echo -e "$RES"| cut -d " " -f 6)
+
+ # set flip command
+ case "$FLIPCMD" in
+ right )
+ FLIP="pnmflip -rotate270"
+ SWAPRES=$X_RES;X_RES=$Y_RES;Y_RES=$SWAPRES
+ ;;
+ left )
+ FLIP="pnmflip -rotate90";
+ SWAPRES=$X_RES;X_RES=$Y_RES;Y_RES=$SWAPRES
+ ;;
+ *)
+ FLIP="cat";
+ ;;
+ esac
+ # Save config for plugin as readable file
+ echo "$X_RES" "$Y_RES" "$FLIPCMD" > "$PARFILE"
+
+ # define aspect ratio depends plugin setup
+ if [ $ASPECT_RATIO = "16:9" ] ; then
+ SCALE_MIN_ASP=163
+ SCALE_MAX_ASP=178
+ else
+ SCALE_MIN_ASP=125
+ SCALE_MAX_ASP=133
+ fi
+
+ # if zoom image, zoom it with factor
+ if [ "$ZOOMFACTOR" -gt 0 ] ; then
+
+ ZOOM_X=$(($X_RES*$ZOOMFACTOR))
+ ZOOM_Y=$(($Y_RES*$ZOOMFACTOR))
+
+ $FLIP < "$TMPFILE" | pnmscalefixed -xysize $ZOOM_X $ZOOM_Y | \
+ pnmcut -pad -left $LEFTPOS -top $TOPPOS -width $OUT_DISPLAY_X -height $OUT_DISPLAY_Y \
+ > "$OUTFILE"
+
+ # else scale image to TV Screensize
+ else
+
+ if [ "$((${X_RES}00 / ${Y_RES}))" -lt $SCALE_MIN_ASP ] ; then
+ OUT_DISPLAY_X=$((${OUT_DISPLAY_Y}000 / $Y_RES * $X_RES / 1000))
+ elif [ "$((${X_RES}00 / ${Y_RES}))" -gt $SCALE_MAX_ASP ] ; then
+ OUT_DISPLAY_Y=$((${OUT_DISPLAY_X}000 / $X_RES * $Y_RES / 1000))
+ fi
+
+ $FLIP < "$TMPFILE" | \
+ pnmscalefixed -xysize $OUT_DISPLAY_X $OUT_DISPLAY_Y \
+ > "$OUTFILE"
+
+ fi
+ # if'nt tmpfile use for next view, remove tmp file
+ [ "z$TMPCACHE" = "zno" ] && rm -f "$TMPFILE"
+ fi
+ fi
+
+ if [ -s "$OUTFILE" ] ; then
+ [ "z$VERBOSE" = "zyes" ] && echo "Success! Stopped with created $OUTFILE"
+ exit 0 # Creation seem success, tell it with 'exit 0' to plugin
+ fi
+ [ "z$VERBOSE" = "zyes" ] && echo "Error! Stopped without found created $OUTFILE, converting should failed !"
+ exit 1 # Hmm, created is failed tell it with 'exit 1' to plugin
+
+
+###### >>>>>>> !!! Only one of the follow lines are allowed (begins always with 2>&1 ) !!!
+### Dump any message to syslog to see use cat /var/log/messages | grep imageplugin
+} 2>&1 | logger -s -t "$SCRIPTNAME"
+### If your wish don't any message logging
+# 2>&1 > /dev/null
+### If your wish old style message logging
+# 2>&1 > /tmp/image/convert.log
diff --git a/scripts/mount.sh b/scripts/mount.sh
new file mode 100755
index 0000000..65cb6e0
--- /dev/null
+++ b/scripts/mount.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# This script is called from VDR to mount/unmount/eject
+# the sources for MP3 play and/or image sources,
+#
+# argument 1: wanted action, one of mount,unmount,eject,status
+# argument 2: mountpoint to act on
+#
+# mount,unmount,eject must return 0 if succeeded, 1 if failed
+# status must return 0 if device is mounted, 1 if not
+#
+# ok -> changed mount to not abort, if eject -t did fail, e.g. for a usb storage device
+
+action="$1"
+path="$2"
+
+case "$action" in
+mount)
+ eject -t "$path" &>/dev/null # close the tray, but not do/print anything if that fails
+ mount "$path" || exit 1 # mount it
+ ;;
+unmount)
+ umount "$path" || exit 1 # unmount it
+ ;;
+eject)
+ eject "$path" || exit 1 # eject disk
+ ;;
+status)
+ cat /proc/mounts | grep -q "$path" # check if mounted
+ if [ $? -ne 0 ]; then # not mounted ...
+ exit 1
+ fi
+esac
+
+exit 0