home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netpbma.zip / pnm / anytopnm.cmd < prev    next >
OS/2 REXX Batch file  |  1997-04-20  |  5KB  |  190 lines

  1. extproc sh
  2.  
  3. #!/bin/sh
  4. #
  5. # anytopnm - attempt to convert an unknown type of image file to a P?M file.
  6. #
  7. # Copyright (C) 1991 by Jef Poskanzer.
  8. #
  9. # Permission to use, copy, modify, and distribute this software and its
  10. # documentation for any purpose and without fee is hereby granted, provided
  11. # that the above copyright notice appear in all copies and that both that
  12. # copyright notice and this permission notice appear in supporting
  13. # documentation.  This software is provided "as is" without express or
  14. # implied warranty.
  15.  
  16. if [ ! $# = 1 ] ; then
  17.     echo "usage: $0 <file>" 1>&2
  18.     exit 1
  19. fi
  20.  
  21. origfile="$1"
  22. file="$origfile"
  23. tmpfiles=""
  24.  
  25. while true ; do
  26.  
  27.     filetype=`file "$file"`
  28.  
  29.     case "$filetype" in
  30.  
  31.         *PBM* | *PGM* | *PPM* )
  32.         cat "$file"
  33.         break
  34.         ;;
  35.  
  36.         *compress* )
  37.         newfile="/tmp/atn.comp.$origfile"
  38.         rm -f "$newfile"
  39.         zcat < "$file" > "$newfile"
  40.         file="$newfile"
  41.         tmpfiles="$tmpfiles $newfile"
  42.         ;;
  43.  
  44.         *btoa* )
  45.         newfile="/tmp/atn.btoa.$origfile"
  46.         rm -f "$newfile"
  47.         atob < "$file" > "$newfile"
  48.         file="$newfile"
  49.         tmpfiles="$tmpfiles $newfile"
  50.         ;;
  51.  
  52.         *Sun* | *rasterfile* )
  53.         rasttopnm "$file"
  54.         break
  55.         ;;
  56.  
  57.         *GIF* )
  58.         giftoppm "$file"
  59.         break
  60.         ;;
  61.  
  62.         *TIFF* )
  63.         tifftopnm "$file"
  64.         break
  65.         ;;
  66.  
  67.         *IFF*ILBM* )
  68.         ilbmtoppm "$file"
  69.         break
  70.         ;;
  71.  
  72.         *Lisp* )
  73.         lispmtopgm "$file"
  74.         break
  75.         ;;
  76.  
  77.         *PC*Paintbrush* )
  78.         pcxtoppm "$file"
  79.         break
  80.         ;;
  81.  
  82.         *Bennet* )
  83.         ybmtopbm "$file"
  84.         break
  85.         ;;
  86.  
  87.         * )
  88.         # Can't figure out the file type from the magic number,
  89.         # try the extension.
  90.         case "$file" in
  91.  
  92.             *.pbm | *.pbm.* | *.pgm | *.pgm.* | *.ppm | *.ppm.* )
  93.             cat "$file"
  94.             ;;
  95.             *.x | *.x.* | *.xbm | *.xbm.* | *.x10bm | *.x10bm.* | *.x11bm | *.x11bm.* | *.bitmap | *.bitmap.* )
  96.             xbmtopbm "$file"
  97.             ;;
  98.             *.r | *.r.* | *.rast | *.rast.* )
  99.             rasttopnm "$file"
  100.             ;;
  101.             *.mac | *.mac.* | *.macp | *.macp.* )
  102.             macptopbm "$file"
  103.             ;;
  104.             *.g3 | *.g3.* | *.fax | *.fax.* )
  105.             g3topbm "$file"
  106.             ;;
  107.             *.xwd | *.xwd.* | *.x10wd | *.x10wd.* | *.x11wd | *.x11wd.* )
  108.             xwdtopnm "$file"
  109.             ;;
  110.             *.brush | *.brush.* )
  111.             brushtopbm "$file"
  112.             ;;
  113.             *.img | *.img.* )
  114.             gemtopbm "$file"
  115.             ;;
  116.             *.pcx | *.pcx.* )
  117.             pcxtoppm "$file"
  118.             ;;
  119.             *.pic | *.pic.* | *.pict | *.pict.* | *.pict2 | *.pict2.* )
  120.             picttoppm "$file"
  121.             ;;
  122.             *.tif | *.tif.* | *.tiff | *.tiff.* )
  123.             tifftopnm "$file"
  124.             ;;
  125.             *.fs | *.fs.* | *.face | *.face.* )
  126.             fstopgm "$file"
  127.             ;;
  128.             *.hips | *.hips.* )
  129.             hipstopgm "$file"
  130.             ;;
  131.             *.fits | *.fits.* )
  132.             fitstopgm "$file"
  133.             ;;
  134.             *.gif | *.gif.* )
  135.             giftoppm "$file"
  136.             ;;
  137.             *.iff | *.iff.* | *.ilbm | *.ilbm.* )
  138.             ilbmtoppm "$file"
  139.             ;;
  140.             *.lispm | *.lispm.* )
  141.             lispmtopgm "$file"
  142.             ;;
  143.             *.mtv | *.mtv.* )
  144.             mtvtoppm "$file"
  145.             ;;
  146.             *.qrt | *.qrt.* )
  147.             qrttoppm "$file"
  148.             ;;
  149.             *.tga | *.tga.* | *.targa | *.targa.* )
  150.             tgatoppm "$file"
  151.             ;;
  152.             *.xim | *.xim.* )
  153.             ximtoppm "$file"
  154.             ;;
  155.             *.xpm | *.xpm.* | *.xpm2 | *.xpm2.* )
  156.             xpmtoppm "$file"
  157.             ;;
  158.             *.pi1 | *.pi1.* )
  159.             pi1toppm "$file"
  160.             ;;
  161.             *.pi3 | *.pi3.* )
  162.             pi3topbm "$file"
  163.             ;;
  164.             *.spu | *.spu.* )
  165.             sputoppm "$file"
  166.             ;;
  167.             *.spc | *.spc.* )
  168.             spctoppm "$file"
  169.             ;;
  170.             *.ybm | *.ybm.* | *.face | *.face.* )
  171.             ybmtopbm "$file"
  172.             ;;
  173.             * )
  174.             echo "$0: unknown file type" 1>&2
  175.             exit 1
  176.             ;;
  177.  
  178.         esac
  179.         break
  180.         ;;
  181.  
  182.     esac
  183.  
  184. done
  185.  
  186. if [ "$tmpfiles" ] ; then
  187.     rm -f $tmpfiles
  188. fi
  189. exit 0
  190.