opImage User Manual


In order to use the opImage extension, it's necessary to create an IIS virtual directory with the correct execute permissions. A VBS (Visual Basic Script) file called setup.vbs is supplied with the installer, and will be automatically run as part of the standard installation. If this script fails, or you need to install opImage on another computer, you will need to create the directories yourself.

Using an existing CGI directory

If you already have a virtual directory within your website that has 'Execute' permissions (often referred to as a cgi-bin directory) you should be able to use that. Simply copy the img.dll file from the bin installation directory into your existing cgi-bin directory and skip the following steps.

Creating a virtual directory

Open the Internet Service Manager console, find the website that you want to use and right click on it. Select New|Virtual Directory from the pop-up menu. You should see the 'Welcome to the Virtual Directory Creation Wizard' page. Click Next and you should see the following page.

This is where you select the name for the virtual directory. The name you choose will be part of the URL to access the extension. Using the example below would result in a URL like this to use opImage:

Next you need to select the directory where the img.dll is located. The following example assumes you've installed the extension into the default location: C:\Program Files\OpImage\
There is a subdirectory in that folder called bin that contains the DLL.

Finally, set the correct permissions for the directory. You need to un-check Read and Run Scripts(by default they are set by the wizard when you enter this page), the only thing that should be set for this folder is Execute. Once this is done, hit Next to complete the wizard.

In order to check your installation, try entering the following URL:
(replacing www.yoursite.com with the domain name of your website, and bin if you entered a different name for the virtual directory in the first step above). You should see a page showing statistics about the opImage extension:

Registry settings

All settings for the extension are stored under the following registry key:
Default values can be restored by double clicking file settings.reg that is part of the installation.

Default value: 10485760 (10mb)
Controls how large the cache of zoomed images will grow.

Default value: 0 (disabled)
Determines whether or not diagnostic output is written to a file. Log files are created in the root of the C drive.

Type: String
Default value: InstallDirector\Example\Images\
The directory where the images are located. The path should always be slash terminated.

Default value: 1
Flag indicating whether to restrict access to flush/stats functions to connections from localhost. This prevents normal web site users seeing or interfering with the opImage cache.

Using opImage


opImage caches the zoomed images that it returns to the browser. It is up to you how much hard disk space you let the cache consume. When an images is returned from the cache, it uses a lot less processor time on the server, so it is best to set the cache as large as possible. Remember the zoomed images in the cache are in JPG format so will be fairly small, the default cache size of 10MB will hold hundreds of them.

As well as caching zoomed images on disk, opImage also caches the original image in memory. If you are using a lot of different images this could result in a large amount of memory being used by the IIS process (inetinfo.exe and dllhhost.exe Windows 2000 or mtx.exe Windows NT. If this happens, flush the caches or restart IIS (using iisreset.exe on Windows 2000 or Service Manager on Windows NT).



When the DLL is called without a command, e.g. /bin/img.dll it expects to be passed parameters in order to generate the zoomed image. If they are not used a Bad Request error will be returned. The correct format when calling the extension is:

The parameters are:
srcThe name of the original, large BMP file. A path/directory should not be specified here. Use the ImageDirectory registry setting instead.
tThe top position of the section from the original image
lThe left position of the section from the original image
swThe width of the section from the original image
shThe height position of the section from the original image
wThe width of the resulting image
hThe height of the resulting image


Assuming we have an image that is 1000 pixels wide by 1000 pixels high, using this command we can get a section from the top left that is 500 pixels by 500 pixels and display it as a 100 x 100 pixel image.
Original image (with sections shown in colours):

Using these parameters:
The resulting image (for demo purposes only, this image is not actually 100x100!):

If we then change the parameters to:
We get a different area of the original image, we have 'moved' the viewport:

If we then change the parameters to:
We zoom in, centered on the same point:

Be sure to check the demo ASP files for the (very simple) maths behind the zoom/in out effect, and how to implement it in a web page.


The command stats is used to display cache statistics. E.g. /bin/img.dll?stats. By default, and if the LocalAdminOnly flag is set, only users connecting from localhost will be able to run this command.


The flush command can be used to empty the file and handle cache. E.g. /bin/img.dll?flush. By default, and if the LocalAdminOnly flag is set, only users connecting from localhost will be able to run this command.


opImage writes information into log files named img1.log located on the root of the drive where the DLL is located. If multiple copies of the DLL are being used, there may be more than one log file (img2.log, img3.log etc).

If images are not being displayed, check the log file for errors. Ones to watch include 'access denied' errors (GetLastError: 5), which often result from the user that the web site is being run as not having read/write access on the TEMP directory. Log file entries containing "Failed opening file ... to get file size (GetLastError: 32)" are normal. Also if the path in the ImageDirectory registry entry is not slash-terminated, you will see "Failed to write JPG file from ..." errors.


Currently only one copy of opImage can be used on each server. Even if multiple copies of the DLL in different virtual directories are used, they will all use the same registry settings, and therefore read their images from the same directory. This will be fixed in a future version.

Output image sizes must be a power of 4. E.g. /bin/img.dll?src=example.bmp&t=400&l=400&sw=500&sh=500&w=100&h=100 will be fine, as 100 is a power of 4, but w=102&h=102 will produce a distorted image.


The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. This software is based in part on the work of the Independent JPEG Group