ColumnIntroducing Title Zoomify Image Adam EditorSmith

Zoomify Image is a mature product most users and allows them to view access to the full data of the original for easily publishing large, high-reso- images interactively in much greater image. detail than would otherwise be prac­ lution images on the Web. End users tical or even possible.1 view these images with existing Web- Zoomify Image (sourceforge.net/ Deploying browser software as quickly as they projects/zoomifyimage) was created Zoomify Image do normal, downsampled images. A at Cornell University in collabora­ tion with Zoomify to create an open- Dependencies and winstal- Flash-based Zoomifyer client asyn- source, cross-platform, and scriptable lation chronously streams image data to the version of the processing software Web browser as needed, resulting in that creates the image data displayed Zoomify Image was designed ini­ tially to be a faithful, cross-platform response times approaching those of in a Zoomifyer client. This work was immediately integrated into an inno­ port of Zoomify’s image-processing desktop applications using minimal vative content-management system software. It was developed in close bandwidth. The author, a librarian at that was being developed within the cooperation with Zoomify to pro­ Cornell University and the principal Zope Application Server, a premier vide a scriptable method for invok­ Web application and publishing plat­ ing the image-preparation process architect of a small, open-source com- form. Authors in this system can for Zoomifyer clients so this technol­ pany, worked closely with Zoomify add high-resolution images just as ogy could be used in more environ­ to produce a cross-platform, open- they normally add downsampled ments. source implementation of that com- images, and the image is automat­ Zoomify Image is written in the ically processed on the server by Python programming language and pany’s image-processing software Zoomify Image and displayed within uses the third-party Python Imaging and discusses how to easily deploy a Zoomifyer client. Zoomify Image is Library (PIL) with JPEG support, the product into a widely used Web- now in its second major release on both of which are also open source and cross-platform. It has been tested publishing environment. Limitations Source Forge and contains user con­ tributed software to easily deploy it in the following environments: are also discussed as are areas of in other environments such as PHP. improvement and alternatives. Zoomifyer has been used in a ■ Python 2.1.3 number of applications in many ■ PIL 1.1.3 fields, and can greatly enhance many oomifyer from Zoomify (www research and instructional activities. and .zoomify.com) enables users Applying Zoomifyer to digital-image Zto view large, high-resolu­ collections is obvious, allowing ■ Python 2.4.3 tion images within existing Web- libraries to deliver an unprecedented ■ PIL 1.1.4 browser software while providing level of detail in images published a rich, interactive user experience. to the Web. New applications also Installers for Python and PIL exist A small Zoomifyer client, authored suggest themselves, such as serving for all major platforms and can be in Macromedia Flash, is embedded high-resolution images taken from obtained at python.org and www in an HTML page and makes asyn­ tissue samples in a medical lab or .pythonware.com/products/pil. chronous requests to the server to using Zoomifyer in advanced geo­ The installation documentation stream image data back to the client spatial image applications, particu­ that comes with PIL will help you as needed. By streaming the image larly when advanced client features locate the appropriate JPEG libraries data in this way, the image renders as such as annotations are used. if they are missing from your system. quickly as a normal, downsampled The Zoomifyer approach also has For MacOSX, you can find pre-built image, even for images that are giga­ positive implications for preservation binary installers for Python, PIL and bytes in size. As the user pans and and copyright protection. Zoomify Zope at sourceforge.net/projects/ zooms, the response time approaches Image generates cached derivatives mosxzope. that of desktop applications while of master image files so the image using the smallest possible band­ masters are never directly accessed width necessary to render the image. in the application or sent over the And because Flash has 98.3 per­ Internet. Image data are stored and Adam Smith ([email protected]) is a cent browser saturation, viewing transmitted to the client in small Systems Librarian at Cornell University “Zoomified” images is seamless for chunks so that end users do not have Library, Ithaca, New York. Author ID box for 3 column layout

48 INFORMATION TECHNOLOGY AND LIBRARIES | March 2007 The “EZ” version of the Zoomifyer extension, the directory is named Zoomify Image objects appears. client, a Flash-based applet with basic by appending “_data” to the image After selecting this option, a form pan and zoom functionality, is pack­ name, so that an image file named is presented that is identical to the aged with Zoomify Image for conve­ “test” would have a corresponding form used for adding ordinary Image nience so the software can be used directory called “test_data.” If the objects within Zope. When an image immediately once installed. The EZ process is re-run on the same images, is uploaded using this form, Zope client is covered by a separate license any previously generated data are automatically invokes the Zoomify and can be easily replaced with more automatically deleted before being Image conversion process on the advanced clients from Zoomify at regenerated. server and links the generated data www.zoomify.com. (A description of Zoomify provides substantial to the default Zoomifyer client that how to upgrade the Zoomifyer client documentation and sample code on comes with the distribution. If the is included in this paper.) its Web site that demonstrates how image is subsequently edited within After Python and PIL with JPEG to use the data generated by Zoomify ZMI to upload a new version, any support are installed, download Image in several environments. User- existing conversion data for that the Zoomify Image software from contributed code is bundled with image are automatically deleted, and sourceforge.net/projects/zoomify­ Zoomify Image itself, further dem­ the new conversion data are gener­ image and decompress it. onstrating how to dynamically incor­ ated to replace them, just as when porate this conversion process into invoked on the command line. several environments. An example of Again, the uploaded image can be Using Zoomify Image the use of Zoomify Image within the in any format that Zope recognizes as from the command line Zope Application Server is given. having a content-type of “image/...” and that PIL can read. The only Begin exploring Zoomify Image by potential “gotcha” in this process is invoking it on the command line: Incorporating Zoomify that in the versions of the Zoomifyer client the author has tested, Zoomify python /ZoomifyFilePr Image into the Zope Image objects that have file names ocessor.py Application Server (in Zope terminology, the file name is the object’s “id” property) with Or, to process more than one file at The popular Zope Application Server extensions other than “.jpg” are not a time: contains a number of built-in services displayed properly by the Zoomifyer including a Web server, FTP and client. So, when uploading a TIFF python /ZoomifyFile WebDAV servers, plug-ins for access­ image, for example, the id given Processor.py ing relational databases, and a hier­ to the Zoomify Image object should archical object-oriented database that either not contain an extension, or it uses a file-system metaphor for stor­ should be changed from image.tif to The file format of the images input age. This object database provides a something like image_tif. This bug to Zoomify Image are typically either unique opportunity to incorporate has been reported to Zoomify and TIFF or JPEG, but can be any of the Zoomifyer into Zope seamlessly. may be fixed in newer versions of the many formats that PIL can read.2 An To use Zoomify Image with Zope, Flash-based viewing software at the image called “test.jpg” is included in the distribution must be decom­ time of publication. the Zoomify Image distribution and pressed into your Zope Products To view the image within the is of sufficient size and complexity to directory. For versions 2.7.x and up, Zoomifyer client, simply call the provide an interesting example. this is at: “view” method of the object from During processing, Zoomify within a browser. So, for a Zoomify Image creates a new directory to /Products/ Image object uploaded to: hold the converted image data in the same location as the image file being In Zope versions prior to the 2.7.x http:///test/test.jpg processed. The name of this direc­ series, the Products directory is at: tory is based on the file name of the go to this URL: image being processed, so that, for /lib/python/ example, an image called “test.jpg” Products/ http:///test/test. would have a corresponding folder jpg/view called “test” containing the converted Restart Zope and now within image data used by the Zoomifyer the Web-based Zope Management Or, to include this view of the client. If the image file has no file Interface (ZMI), the ability to add image within a Zope Page Template

Introducing Zoomify Image | SMITH 49 is further divided into tiles that are, lower-numbered tiles, so 0-0-0.jpg is (ZPT), simply call the tag method of at most, 256 pixels wide by 256 pixels always in TileGroup0. the Zoomify Image just as you would tall, as seen in figure 1. Zoomifyer clients understand a normal Image object in Zope. So, in These tiles are created left to this tile-naming scheme and only a ZPT, use this: right, top to bottom. Tiles are saved request tiles from the server that are as images with the naming conven­ necessary to stitch together the por­ The numbering is zero-based, so particular scale. that the smallest tier is represented It is possible that the Zoomify by one tile that is at most 256 x Image conversion process will not 256 pixels wide with the name “0-0- Limitations have had time to complete when 0.jpg.” someone tries to view the image. The Tiles are saved in directories in Zoomify Image was developed to Zoomify Image object will attempt to groups of 256, and those directories meet two goals: degrade gracefully in this situation also follow a zero-based naming con­ by trying to display a downsampled vention starting with “TileGroup0.” 1. to provide a cross-platform version of the image that is gener­ Lower-numbered tile groups contain port of the Zoomifyer con­ ated part way through the conver­ sion process, or, if that is also not available, finally informing the user that the image is not yet ready to be viewed. This logic is built into the tag method. To add larger images more effi­ ciently, or to add images in bulk, the Zoomify Image distribution contains detailed documentation to quickly configure Zope to accept images via FTP or WebDAV and automatically process them through Zoomify Image when they are uploaded. Finally, the default Zoomifyer cli­ ent can be overridden by uploading a custom Zoomifyer client into a loca­ tion where the Zoomify Image object can “acquire” it, and giving it a Zope id of “zoomifyclient.swf”. Figure 1. Tiers and tiles for a 2048 x 2048 pixel image How it works

To be viewed by a Zoomifyer cli­ ent, an image must be processed to produce tiles of the image at differ­ ent scales, or tiers. An XML file that describes these tiles is also necessary. Zoomify Image provides a cross- platform method of producing these tiled images and the XML file that describes them. Beginning at 100-percent scale, the image is successively scaled in half to produce each tier, until both the width and height of the final tier are, at most, 256 pixels each. Each tier Figure 2. Tile image naming scheme

50 INFORMATION TECHNOLOGY AND LIBRARIES | March 2007 verter for use in UNIX/ and relatively inexpensive. Running Conclusion systems, and the latest versions of Python and 2. to make the converter script­ PIL will also help. Each new version Zoomify Image is mature, open- able, and ultimately integrate it of Python makes significant perfor­ source software that makes it pos­ into open-source content-man­ mance improvements, and this was sible to publish large, high-resolution agement software, particularly a primary goal of version 2.5, which images to the Web. It is designed Zope. was released in September 2006. to be convenient to use in a variety The author believes that the cur­ of architectures and can be viewed This Zoomifyer port was writ­ rent weak link in the performance within existing browser software. ten in Python, a mature, high-level chain is related to how Zoomify Image Download it for free, begin using it programming language with an is loading image data into memory in minutes, and explore its unique execution model similar to Java. with PIL during processing. In the possibilities. Although Zoomify Image continues current distribution, a Python script to be optimized, compared to the contributed by Gawain Avers, which References official Zoomify conversion software, is based partially on the Zoomify it is slower and more limited in the Image approach, uses ImageMagick 1. Adobe Systems, Macromedia Flash sizes of images it can reasonably instead of PIL for image manipula­ Player Statistics, http://www.adobe.com/ process. Anecdotally, Zoomify Image tion and is better able to process products/player_census/flashplayer/ has been used effectively on images multi-gigabyte images. The author (accessed March 1, 2007). hundreds of megabytes large, but would like to add the ability to des­ 2. PythonWare, Python Imaging Library significant performance degradation ignate the image library at runtime in Handbook: , http:// has been reported in the multi-giga­ future versions of Zoomify Image. www.pythonware.com/library/pil/ byte range. handbook/formats.htm (accessed Aug. 6, Because of these limitations in 2006). Zoomify Image, the official Zoomify image-processing software is recom­ Future development Resources mended for converting very large images manually in a Windows or Beyond improving the performance Macromedia Flash Player Statistics Macintosh environment. The Zoomify of the core-processing algorithm, the (http://www.adobe.com/ Image product is recommended in author would also like to explore products/player_census/flash­ the following circumstances: opportunities for more efficiently player/) (accessed Jan. 2, 2007). processing images within Zope, such Python Imaging Library (PIL) (http:// www.pythonware.com/products/ ■ The conversion must be per­ as spawning a background thread pil/) (accessed Jan. 2, 2007). formed on a UNIX/Linux for processing images so the Zope Python Programming Language Official machine. Web server can immediately respond Web site (http://www.python.org/) ■ The conversion process must be to the client’s image-submission (accessed Jan. 2, 2007). scriptable, such as for batch pro­ request. The author would also like Zoomify Image (http://sourceforge.net/ cessing or being run dynamically. to improve the tag method to display projects/zoomifyimage/) (accessed ■ Images sizes are not in the multi- data more flexibly in the Zoomifyer Jan. 2, 2007). gigabyte range. client and ensure consistent behav­ Zoomify (http://www.zoomify.com/) ior with Zope’s default Image tag (accessed Jan. 2, 2007). If a scriptable, cross-platform method. Finally, Zoomify Image Zope Community (http://www.zope .org/) (accessed Jan. 2, 2007). version of the Zoomifyer converter could also benefit from the addi­ Zope installers for MacOSX (http:// is needed, but performance is an tion of a simple configuration file to sourceforge.net/projects/ issue, several things can be done to control such runtime properties as mosxzope/) (accessed Jan. 2, 2007). extend the current limits of the soft­ image quality and which third-party ware. Obviously, upgrading hard­ image-processing library to use, for ware, particularly RAM, is effective example.

Introducing Zoomify Image | SMITH 51