summaryrefslogtreecommitdiff
path: root/ipl/gprocs/gifsize.icn
diff options
context:
space:
mode:
Diffstat (limited to 'ipl/gprocs/gifsize.icn')
-rw-r--r--ipl/gprocs/gifsize.icn51
1 files changed, 51 insertions, 0 deletions
diff --git a/ipl/gprocs/gifsize.icn b/ipl/gprocs/gifsize.icn
new file mode 100644
index 0000000..b6dd9a3
--- /dev/null
+++ b/ipl/gprocs/gifsize.icn
@@ -0,0 +1,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