makexvpics-1.0.1.orig/0042711000175000000500000000000006737751625013475 5ustar quangosrcmakexvpics-1.0.1.orig/makexvpics.10100600000175000000500000000316506737751243015725 0ustar quangosrc.\" -*- nroff -*- .\" .\" makexvpics - create xv-compatible thumbnails. .\" Public domain by Russell Marks, 1998/1999. .\" .\" .\" makexvpics.1 - nroff -man source for man page. .\" .\" .TH MAKEXVPICS 1 "4th July, 1999" "Version 1.0.1" "Graphics Utilities" .\" .\"------------------------------------------------------------------ .\" .SH NAME makexvpics \- create xv-compatible thumbnails .\" .\"------------------------------------------------------------------ .\" .SH SYNOPSIS .BR makexvpics " [ " -fhRv .RI "] " picture_file_or_dir " [ " ... " ]" .\" .\"------------------------------------------------------------------ .\" .SH DESCRIPTION Makexvpics creates/updates xv/zgv/Gimp-compatible thumbnails for picture files such as GIFs, JPEGs, etc. It may be useful if you want a non-interactive way of keeping such files up to date. .PP The formats currently supported are GIF, JPEG, PNG, PBM/PGM/PPM, mrf, BMP, TGA, and PCX. .\" .\"------------------------------------------------------------------ .\" .SH OPTIONS .TP .I -f force thumbnails to be updated. Ordinarily they're only updated if no thumbnail exists or if the picture file is newer. .TP .I -h give usage help. .TP .I -R recurse into subdirectories. .TP .I -v be verbose - echo names (or rather, `basename's) of files which are being updated. .\" .\"------------------------------------------------------------------ .\" .SH BUGS It's pretty slow. .\" .\"------------------------------------------------------------------ .\" .SH AUTHOR Russell Marks (rus@forfree.at). .\" .\"------------------------------------------------------------------ .\" .SH SEE ALSO .BR xv "(1)," .BR zgv "(1)" makexvpics-1.0.1.orig/Makefile0100600000175000000500000000177006726512305015121 0ustar quangosrc# makefile for ppmtoxvmini (also installs makexvpics) # If you only have a K&R C compiler (surely just about impossible # these days, but just in case...), uncomment this: #KRDEF=-DKANDR CFLAGS = -O $(KRDEF) # these are where makexvpics and ppmtoxvmini are installed PREFIX = /usr/local BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/man/man1 # You shouldn't need to modify anything below this line. all: ppmtoxvmini ppmtoxvmini: ppmtoxvmini.o $(CC) $(CFLAGS) -o ppmtoxvmini ppmtoxvmini.o install: all install -m 511 -s ppmtoxvmini $(BINDIR) install -m 555 makexvpics.sh $(BINDIR)/makexvpics install -m 444 makexvpics.1 $(MANDIR) clean: $(RM) *.o *~ ppmtoxvmini VERS=1.0.1 tgz: ../makexvpics-$(VERS).tar.gz # Based on the example in ESR's Software Release Practice HOWTO. # ../makexvpics-$(VERS).tar.gz: clean $(RM) ../makexvpics-$(VERS) @cd ..;ln -s makexvpics makexvpics-$(VERS) cd ..;tar zchvf makexvpics-$(VERS).tar.gz \ --exclude='*/sav' makexvpics-$(VERS) @cd ..;$(RM) makexvpics-$(VERS) makexvpics-1.0.1.orig/ppmtoxvmini.c0100600000175000000500000000556206705711135016221 0ustar quangosrc/* ppmtoxvmini - convert PPM to `xvpic', and generate PPM 3:3:2 map. * PD by RJM */ #include #include #ifdef KANDR #define void int #endif unsigned char input[80*60*3],output[80*60]; int map[256*3]; /* output 3:3:2 palette as PPM */ void writemap() { int f; printf("P6\n256 1\n255\n"); for(f=0;f<256;f++) printf("%c%c%c",map[f*3],map[f*3+1],map[f*3+2]); } void educate_luser() { /* revolting for maximum portability :-/ */ fprintf(stderr, "\nppmtoxvmini is a simple mapped-PPM-to-xvpic program which relies on\n"); fprintf(stderr, "other programs to do the hard work. Here's an example use of ppmtoxvmini:\n"); fprintf(stderr, "\nppmtoxvmini -genmap >map\n"); fprintf(stderr, "djpeg -fast foo.jpg | pnmscale -xysize 80 60 | ppmquant -fs -map map | \\\n"); fprintf(stderr, "\tppmtoxvmini >.xvpics/foo.jpg\n\n"); fprintf(stderr, "However, ppmtoxvmini is not really designed to be used directly; you're\n"); fprintf(stderr, "probably better off using `makexvpics'.\n"); exit(1); } #ifdef KANDR main(argc,argv) int argc; char *argv[]; #else int main(int argc,char *argv[]) #endif { FILE *in=stdin; unsigned char *ptr; char buf[128]; int x,y,f,w,h,r,g,b,tmp,*iptr; /* generate 332 map */ iptr=map; for(r=0;r<8;r++) for(g=0;g<8;g++) for(b=0;b<4;b++) { *iptr++=r*255/7; *iptr++=g*255/7; *iptr++=b*255/3; } if(argc==2 && strcmp(argv[1],"-genmap")==0) writemap(),exit(0); if(argc==2) if((in=fopen(argv[1],"rb"))==NULL) fprintf(stderr,"ppmtoxvmini: couldn't open input file.\n"),exit(1); if(in!=stdin) fclose(in); fgets(buf,sizeof(buf),in); if(strcmp(buf,"P6\n")!=0) fprintf(stderr,"ppmtoxvmini: not a raw PPM file.\n"),exit(1); do fgets(buf,sizeof(buf),in); while(buf[0]=='#'); if(sscanf(buf,"%d%d",&w,&h)!=2) fprintf(stderr,"ppmtoxvmini: not a raw PPM file.\n"),exit(1); if(w>80 || h>60) fprintf(stderr,"ppmtoxvmini: input file bigger than 80x60.\n"), educate_luser(); do fgets(buf,sizeof(buf),in); while(buf[0]=='#'); if(sscanf(buf,"%d",&tmp)!=1) fprintf(stderr,"ppmtoxvmini: not a raw PPM file.\n"),exit(1); if(tmp!=255) fprintf(stderr,"ppmtoxvmini: maxval must be 255 - try `pnmdepth 255'.\n"), exit(1); if(fread(input,1,w*h*3,in)!=w*h*3) fprintf(stderr,"ppmtoxvmini: couldn't read input.\n"),exit(1); ptr=input; for(y=0;y/dev/null xvpicname=${fnambit}/`basename $1` # in order to make the xvpic, it has to either not exist, or be older # than the picture file, or `-f' has to have been specified. # note that we really do mean *exist*, not whether it's readable or not... if [ ! -f "$xvpicname" -o "$1" -nt "$xvpicname" -o "$force" = "y" ]; then if [ "$verbose" = "y" ]; then echo "$1" fi trapdel="$xvpicname" eval "$command" <"$1" 2>/dev/null | pnmscale -xysize 80 60 2>/dev/null | \ ppmquant -fs -map $tempfile.map 2>/dev/null >$tempfile.ppm # any errors above should have resulted in an empty or junk PPM, # which this will spot... ppmtoxvmini <$tempfile.ppm >"$xvpicname" 2>/dev/null || rm -f "$xvpicname" trapdel="" fi } # usage: is_pic possible_picture_file # # tests filetype and permissions etc., and sets $command is_pic() { if [ -f "$1" -a -r "$1" ]; then case `echo $1 | tr [A-Z] [a-z]` in *.jpg|*.jpeg ) command="djpeg -fast -scale 1/4" ;; *.gif ) command=giftopnm ;; *.png ) command=pngtopnm ;; *.pbm|*.pgm|*.ppm ) command=cat ;; *.mrf ) command=mrftopbm ;; *.bmp ) command=bmptoppm ;; *.tga ) command=tgatoppm ;; *.pcx ) if [ "$USE_PCX2PPM" = "y" ]; then command=pcx2ppm else command=pcxtoppm fi ;; * ) command="" return 1 ;; esac return 0 else # if not normal file or not readable return 1 fi } # usage: do_files file1 [file2 ...] # # do files specified. do_files() { local olddir for picture in $*; do if is_pic "$picture"; then make_xvpic "$picture" else # could be a directory... if [ "$recurse" = "y" -a -d "$picture" -a -r "$picture" ]; then olddir=`pwd` cd "$picture" do_files * cd "$olddir" fi fi done } usage() { cat <<'mouse' usage: makexvpics [-fhRv] picture_file_or_dir [...] -f force update of all picture files, new or not -h give this usage help -R recurse in subdirectories -v be verbose - echo (`basename's of) files which are being updated mouse } # starts here tempfile=/tmp/mxvp$$ trapdel="" trap 'rm -f $tempfile.* $trapdel' 0 1 3 15 ppmtoxvmini -genmap >$tempfile.map # parse args set -- `getopt fhRv $*` for i; do case "$i" in -f ) force=y shift ;; -h ) usage exit 1 ;; -R ) recurse=y shift ;; -v ) verbose=y shift ;; -- ) shift break ;; esac done if [ "$1" = "" ]; then usage exit 1 fi # index the files if needed do_files $* exit 0 makexvpics-1.0.1.orig/README0100600000175000000500000000327606737750512014352 0ustar quangosrcmakexvpics - create/update xv/zgv/Gimp-compatible thumbnails non-interactively. Public domain by Russell Marks, 1998/1999. Description ----------- Makexvpics generates thumbnails for picture files (GIFs, JPEGs, etc.) which are suitable for xv, zgv, and the Gimp. It's considerably slower than any of those are at making them (in particular, updating a mostly-up-to-date set of thumbnails is very much slower), but well, it works. :-) Also, being primarily a shell script it's quite easy to add support for additional formats. Makexvpics arose through my being asked more than once to make zgv update thumbnails from the command-line (without going into graphics mode) somehow. Since it's fairly hairy having an svgalib program not call svgalib's vga_init() sometimes, and since it's quite possible xv (and now Gimp) users might want to be able to do something similar without having to have zgv installed, I thought a separate program was the best approach. Requirements ------------ Makexvpics is a fairly simple shell script, and relies on various other programs to do most of the work. In particular, you need these things installed before makexvpics will work: - netpbm (or pbmplus) - djpeg (for JPEG support) - pngtopnm (for PNG support) - mrftopbm (for mrf support) Installation ------------ If you have my `pcx2ppm' program installed, you should uncomment the USE_PCX2PPM definition in `makexvpics.sh'. (But this only makes any difference when indexing PCX files, so most people won't need to care about this either way. :-)) Then edit the Makefile if necessary (it shouldn't be), do `make', then (as root) `make install'. See the man page for details of how to use the program. Share and enjoy! -Rus. makexvpics-1.0.1.orig/ChangeLog0100600000175000000500000000052106737750457015242 0ustar quangosrc1999-07-04 Russell Marks * Version 1.0.1. * README: Gimp 1.1.x uses xv format thumbnails, so makexvpics may be of interest to Gimp users. 1999-06-06 Russell Marks * makexvpics.sh: fixed stupid bug in do_files() - olddir wasn't local, so recursing more than one level used to (usually) screw up.