home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / grfxrexx.zip / LitGIF.Cmd < prev    next >
OS/2 REXX Batch file  |  1995-09-23  |  2KB  |  58 lines

  1. /*********************************************************************
  2.  LitGIF - Raphaël Vanney, 09/95
  3.  
  4.  The purpose of this REXX program is to get information from a GIF file.
  5.  There's of course no waranty of any kind associated to it. Use freely.
  6. **********************************************************************/
  7.  
  8. Debug=1
  9. Parse Arg NomF
  10. Say GetGIFDesc(NomF)
  11. Drop NomF GIF.
  12. Exit
  13.  
  14. GetGIFDesc:
  15. /* Get description for a GIF file ; if first character of returned
  16.    string is a "(", an error occured and the returned string is a
  17.    description of the error rather than of the file.
  18.    Normally returns "width x height (colors)".
  19.    Extra info is available in GIF. if no error occured :
  20.      GIF.bits       bits per pixel (Log2(colors))
  21.      GIF.colors     number of colors
  22.      GIF.bkg        background color
  23.      GIF.width      image width
  24.      GIF.height     image height
  25. */
  26.  
  27. Parse Arg FName
  28. Drop GIF.
  29.  
  30. If FName="" Then Return "(must supply a filename)"
  31.  
  32. /* read file header */
  33.  
  34. Hdr=CharIn(FName, 1, 6)                      /* should return "GIF8?a" */
  35. If SubStr(Hdr, 1, 3)<>"GIF" Then
  36. Do
  37.      rc=CharOut(FName)
  38.      Drop Hdr
  39.      Return "(not a GIF file)"
  40. End
  41.  
  42. CurPos=11
  43.  
  44. GIF.bits=C2D(BitAnd(CharIn(FName, CurPos), D2C(7)))+1
  45. If Debug Then Say "GIF.bits="GIF.bits
  46. GIF.colors=2 ** GIF.bits
  47. GIF.bkg=C2D(CharIn(FName))
  48.  
  49. CurPos=CurPos+3+(3*GIF.colors)+5
  50.  
  51. GIF.width=C2D(Reverse(CharIn(FName, CurPos, 2)))
  52. GIF.height=C2D(Reverse(CharIn(FName, , 2)))
  53.  
  54. Drop CurPos
  55.  
  56. rc=CharOut(FName)
  57. Return GIF.width||" x "||GIF.height||" ("||GIF.colors||" colors)"
  58.