summaryrefslogtreecommitdiff
path: root/ipl/gprocs/gifsize.icn
blob: b6dd9a396e4f5ca433fb97ff30b2f0edebce7b91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
############################################################################
#
#	File:     gifsize.icn
#
#	Subject:  Procedure to return size of GIF file
#
#	Author:   Ralph E. Griswold
#
#	Date:     May 2, 2001
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This procedure returns the size of a GIF file in the form
#  width,height.  It fails if the file does not exist or is
#  not a valid GIF file.
#
############################################################################
#
#  Links:  bincvt
#
############################################################################

link bincvt

procedure gifsize(name)			#: size of GIF file
   local gif, width, height

   gif := open(name) | fail

   repeat {			# only to provide a loop to break out of ...
      read(gif) ? {
         =("GIF87a" | "GIF89a") | break
         width := move(1)
         width := move(1) || width
         width := unsigned(width) | break
         height := move(1)
         height := move(1) || height
         height := unsigned(height) | break
         close(gif)
         return width || "," || height
         } | break
      }

   close(gif)
   fail

end