Jpg2xpm.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
Zeile 11: Zeile 11:
 
# Source: http://www.vdrportal.de/board/thread.php?threadid=14385
 
# Source: http://www.vdrportal.de/board/thread.php?threadid=14385
  
# CONFIG START
+
LOGO_WIDTH=64
  LOGO_WIDTH=64
+
LOGO_HEIGHT=48
  LOGO_HEIGHT=48
+
LOGO_DEPTH=16
  LOGO_DEPTH=16
+
  LOGO_DIR=/tmp/logos
+
# CONFIG END
+
  
mkdir -p $LOGO_DIR
+
for INPUT in `find -maxdepth 1 -name "*.jpg"`;
 
+
do
LOGOS=`find $LOGO_DIR -maxdepth 1 -name "*.jpg"`
+
    echo -n "Processing $INPUT:  "
COUNT=`echo "$LOGOS" | wc -l | tr -d ' '`
+
 
+
for INPUT in $LOGOS ; do
+
    i=$[i+1]
+
 
     OUTPUT=`echo $INPUT | sed 's/^\(.*\)\(\.[^.]*\)$/\1/'`
 
     OUTPUT=`echo $INPUT | sed 's/^\(.*\)\(\.[^.]*\)$/\1/'`
 
     OUTPUT="$OUTPUT.xpm"
 
     OUTPUT="$OUTPUT.xpm"
     echo -e "XXX\n$(($i*100/$COUNT))\n  $i/$COUNT ${INPUT#./*}\nXXX"
+
     BATCHCMD="gimp -i -d -b '(script_fu_tovdr $LOGO_WIDTH $LOGO_HEIGHT $LOGO_DEPTH  \"$INPUT\" \"$OUTPUT\")' '(gimp-quit 0)'"
    if [ ! -e "${OUTPUT#./*}" ] ; then
+
    eval $BATCHCMD
BATCHCMD="gimp -i -d -b '(script_fu_tovdr $LOGO_WIDTH $LOGO_HEIGHT $LOGO_DEPTH  \"$INPUT\" \"$OUTPUT\")' '(gimp-quit 0)'"
+
done
eval "$BATCHCMD"
+
    fi
+
done \
+
| dialog --gauge " " 7 60
+
 
</pre>
 
</pre>
 
}}
 
}}

Version vom 22. April 2006, 02:15 Uhr

Quelle: http://www.vdrportal.de/board/thread.php?threadid=14385

Beschreibung: Skripts zum Konvertieren von Bildern ("jpg") nach ("xpm").

Datei
$HOME/jpg2xpm.sh
#!/bin/sh
#
# jpg2xpm.sh
#
# Source: http://www.vdrportal.de/board/thread.php?threadid=14385

LOGO_WIDTH=64
LOGO_HEIGHT=48
LOGO_DEPTH=16

for INPUT in `find -maxdepth 1 -name "*.jpg"`;
do
    echo -n "Processing $INPUT:  "
    OUTPUT=`echo $INPUT | sed 's/^\(.*\)\(\.[^.]*\)$/\1/'`
    OUTPUT="$OUTPUT.xpm"
    BATCHCMD="gimp -i -d -b '(script_fu_tovdr $LOGO_WIDTH $LOGO_HEIGHT $LOGO_DEPTH  \"$INPUT\" \"$OUTPUT\")' '(gimp-quit 0)'"
    eval $BATCHCMD
done


Datei
$HOME/.gimp-<VERSION>/scripts/jpg2logo.scm
(define (script_fu_tovdr width height depth infile outfile)
(let* ((img (car (file-jpeg-load 1 infile infile)))
(drawable (car (gimp-image-active-drawable img))))

(gimp-image-scale img width height)
(gimp-convert-indexed img 2 0 depth 0 0 "")
(file-xpm-save 1 img drawable outfile outfile 255)))

(script-fu-register "script_fu_tovdr"
_"<Toolbox>/Xtns/Script-Fu/Utils/TOVDR"
"TOVDR"
"niklot"
"niklot"
"2003-03-25"
""
SF-VALUE "Width" "64"
SF-VALUE "Height" "48"
SF-VALUE "Depth" "16"
SF-FILENAME "Infile" "/tmp/infile.jpg"
SF-FILENAME "Outfile" "/tmp/outfile.xpm")