View member feedback to this tip.
This tip resolves a problem faced by many developers who code for the Web: how to create thumbnail images in Lotus Domino. Until I came up with this code, I either ended up with a solution that required manual steps or else I had to use an external program.
The code below uses LS2J to create thumbnail images in LotusScript. LotusScript does not natively have any methods for manipulating images, but Java does. LS2J (which is a part of Notes/Domino on the Win32 platform) makes it possible to expose Java functionality to LotusScript.
This tip employs an agent that is called in the WebQuerySave event of a Domino form. The agent, written in LotusScript, checks the document for image files, and if any are found, creates thumbnail files for them and attaches them to the document. You could create an agent for the Notes client that does the same thing. The central part of the agent is the line that calls the method that creates the thumbnail file. This method (thumbnailObject.ThumbnailThis in the code) receives four parameters:
- The filename of the image that is to be used as the source for the thumbnail file.
- The filename that the thumbnail image should have.
- The maximum width of the thumbnail image.
- The maximum height of the thumbnail image.
I have a form that holds a Body-field and an upload control to allow Web users to attach image files. The form has the following in the WebQuerySave event: @Command([ToolsRunMacro]; "SaveWeb")
In the database I have an agent with the following code:
Below is the Java Library that makes it possible to create the thumbnail – when we make the call for thumbnailObject.ThumbnailThis above.
You creat...
To continue reading for free, register below or login
To read more you must become a member of SearchDomino.com
');
// -->

e a Java Library in the Designer in Shared code->Script Libraries, click New Java Library, and then remove the few lines of code that you get as a help for getting started, and paste the code below.
Save and call the library "ThumbNail".
Jens Bruntt is a senior consultant at Convergens, a Danish company for whom he architects Domino-browser based Internet, intranet and extranet sites. He has been a developer and infrastructure advisor for Notes and Domino projects since 1994 and is an R6 Principal Developer. He is also SearchDomino.com's expert on Web development. Jens gives credit for this tip to Min-Chi Huang, who made sample thumbnailing code available to the openntf.org project, "Open Notes Picture Database."
MEMBER FEEDBACK TO THIS TIP
This is a very useful article. However, be careful about useing doc.save(...) in WebQuerySave-Agent. Nobody knows (not even IBM) what happens. Another problem is the use of "Toolkit.getDefaultToolkit().getImage(inputFilePath);" from the java.awt.* package -- it does not work on Unix/Linux maschines without startet X-Window Server.
Matthias G.
Do you have comments on this tip? Let us know.
Please let others know how useful this tip is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.