Adlib API home page > Documentation > Image handling

Image handling

The wwwopac.ashx offers functionality for efficiently retrieving and safely storing of images. Its high performance for retrieving, scaling and cropping of images for display in the Adlib Media Viewer or for thumbnail display on the brief display of a search result is accomplished by not resizing the images to be retrieved for every request, but by reducing or enlarging the image only when first requested, and then saving the result in a cache folder so that for a following identical request the next time a ready-made resized image can be retrieved. So the use of wwwopac.ashx for retrieving images is most useful if the images to which you link in your (museum) visual documentation records are pretty large files. For use in thumbnail displays, the image handler will scale those images on the server or it'll retrieve earlier created thumbnails, which results in less data traffic on your network, it lightens the workload of the Adlib core software en also diminishes memory use of the work station enormously.
You can also use this functionality to directly and safely store images linked to in a visual documentation record, in an Adlib SQL or Adlib Oracle database, although you can store images in the file system as well.

To be able to work with images, you'll first have to configure the images server. Click here for information about how to configure the images server in the adlibweb.xml file.
The two API functions for retrieving and respectively storing images, are getcontent and writecontent.

Example 1: retrieve an image and fit it, regardless of its size, in a square box of fixed dimensions with a black background:

http://test2.adlibsoft.com/api/wwwopac.ashx?command=getcontent&server=adlibimages&value=OP202.jpg&width=300&height=300&scalemode=fit&canvascolor=black

Example 2: retrieve an image file, scale it to fill a circular box and only show the middle part of the image against a linen background:

http://test2.adlibsoft.com/api/wwwopac.ashx?command=getcontent&server=adlibimages&value=T24ix.jpg&width=200&height=200&scalemode=fill&fillmode=center&cornerradius=100&cornercolor=linen

Instead of just using the file name of the image to retrieve, you may precede it by a partial path to a subfolder of the main images folder, when applicable. From the wwwopac.ashx version of 2011-10-18 you may also use a full URL pointing to an image file, although in that case resized images won't be cached by wwwopac.ashx so you won't profit from the performance benefits otherwise provided by the caching of images.

Note that during the development phase of this functionality, there was talk of separate software named Image Handler which could have been used alongside wwwopac; however, the relevant functionality is now only available as part of wwwopac.ashx.