Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Image Gallery

One thing I have often wanted to do with CityDesk is loop through images. And have automatically generated thumbnails.

I may have gotten one step closer, but as yet haven't got 100% there, but here's what I've got so far:

ASP-Jpeg will manipulate Jpeg files on the (IIS) server for you. Such as take an image and shrink it to specified size.
Available from (it has a 30 day trial period.)

With this installed, I created this template:

Response.Expires = 0

' create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Open source file
Jpeg.Open( Request.ServerVariables("APPL_PHYSICAL_PATH") & "{$ .Headline $}" )

' Set new height and width
Jpeg.Width = {$ .Extra1 $}

' Maintain ratio
Jpeg.Height = Jpeg.OriginalHeight * Jpeg.Width / Jpeg.OriginalWidth

' Perform resizing and
' send resultant image to client browser


I created an article using this template with:
{$ .Headline $} = Magic Name for image file.
{$ .Extra1 $} = New width.

Now, be warned, I have a bug in the above code:
Request.ServerVariables("APPL_PHYSICAL_PATH") will return the correct path, if your images are in the root of the site (e.g.  c:\inetpub\wwwroot). Leaving the images in the root is too messy for my liking, but it works. (There is probably a correct way of working out the path a file is in from asp/vbscript. Let me know if you know it.)

OK, having done all that, actually linking to the image: In an article, insert an image, then change the magic name of the image to the magic name of the article that generates the image. The html code will end up something like this:
<img height="31" alt="" src="PTMFOG0000000024" width="88" border="0" />

So, I'm still a few steps away from looping through images and generating thumbnails from within citydesk, but maybe this will give you guys some ideas. If nothing else, you can certainly loop through the articles that return an image using this.

Let me know if you have any fun with this.

Don Vince
Tuesday, November 9, 2004

You should use

Server.MapPath(".") to get the current directory of the ASP file.

Michael H. Pryor
Fog Creek Software
Tuesday, November 9, 2004

*  Recent Topics

*  Fog Creek Home