Forum OpenACS Q&A: Is there a tcl function to get image size?

Is there a function in either the aolserver api or the tcl procedures
library to return the height and width parameters of an image
residing in the linux filesystem?
Collapse
Posted by Don Baccus on
There are some examples of how to do this scattered around OpenACS 3.2.5.  Just visit one of the modules that allows photo uploads (general comments, bboard) and grep for "jpg" and you'll find the right script quickly enough.
Using the AOLserver API you can get the width & height for a .gif via ns_gifsize, and for a .jpg via ns_jpegsize.

If you want to work in pure Tcl then you might want to look at the Tcl'ers Wiki where you can find examples of how to read the dimensions of .gif, .jpeg, and .png files.

If you are doing lots of image work, you could consider installing ImageMajik.  We use it in the photodb to create thumbnails when photos are uploaded.  It can tell you the size of an image.