[distcc] Using distcc for other tasks (distributed "filtering")
Justin A
justin at bouncybouncy.net
Thu Apr 1 08:02:18 GMT 2004
Hi :-)
I've been playing with distcc to do the same thing, getting it to run
arbitrary things.
I first wrote a forking perl script to distribute jobs over the network with
ssh(now fsh) but it's not very flexible, and I really wanted to see if I could
get distcc to do what I wanted it to do ;)
So as it turns out, getting distcc to resize/scale jpegs is actually very easy.
First you write a Makefile:
CC=/usr/local/bin/jpegcc
.SUFFIXES: .jpeg .c
OUTDIR=rot/
$(OUTDIR)%.jpeg: %.c
$(CC) -o $@ -c $<
rotated := $(patsubst %.c,$(OUTDIR)%.jpeg,$(wildcard *.c))
all: mkdir $(rotated)
mkdir:
[ -d $(OUTDIR) ] || mkdir $(OUTDIR)
clean:
rm -v $(OUTDIR)*.jpeg
that was the easy part, the trick is writing jpegcc:
#!/bin/sh
while getopts c:o:E: c ;do
case $c in
c)
INPUT="$OPTARG"
;;
o)
OUTPUT="$OPTARG"
;;
E)
INPUT="$OPTARG"
cat $INPUT
exit
esac
done
#jpegtran -copy all -rotate 90 -outfile $OUTPUT $INPUT || true
djpeg -scale 1/4 $INPUT |cjpeg -quality 90 -outfile $OUTPUT
The only problem is having to name the source files .c or such, but adding
.jpeg as a source file extension would fix that. But it works, surprisingly
well.
Although in your case, it would be best to write a daemon that works like the
suggested distmp3, one that reads data and writes out zlib compressed data, and
rewrite the compressloop program to use it.
CC replies :-)
--
-Justin
More information about the distcc
mailing list