Subject: RE: Images in web views
As Andre suggested, the best way is to create seperate thumbnail attachments.
Let’s say your view contains 30 images of 100Kb each. When you
tags to resize the image, you are sending 3 Mb (not counting text) to the browser for your view. Usually a small thumbnail image is no larger than 2Kb, so when you use thumbnail images in your view, your view size would be reduced to 60Kb (again, not counting text), or as my calculator claims: an improvement of 5000% !! How about that for speeding up your views… It sure makes the extra 60Kb storage required well worth it.
Any easy way to create this extra thumbnail image, is to use a webquery save agent. I’ve attached some sample code to show you how this can be accomplished.
Note: This code uses a commercial lsx to create the thumbnails. You can find more info on the thumbnailer lsx here: http://www.peopleware.be/peopleware/public/tnreg.nsf
Option Public
Uselsx “Thumbnailer”
Use “ThumbnailUtils”
Sub Initialize
On Error Goto errorhandler
Dim s As notessession
Dim tn As thumbnailer
Dim doc As notesdocument
Dim embeddedobj As notesembeddedobject
Dim attnames As Variant
Dim tmpdir As String
Dim tmpfilename As String
Dim rt As notesrichtextitem
Set s = New notessession
Set tn = New thumbnailer
Set doc = s.documentcontext
'process document only once
If doc.thumbnailcreated(0) <> “” Then Exit Sub
If Not doc.hasembedded Then Exit Sub
'get attachmentname
attnames = Evaluate(|@attachmentnames|, doc)
tmpdir = BuildTempDir()
tmpfilename = tmpdir + attnames(0)
'extract file
Set embeddedobj = doc.GetAttachment(attnames(0))
Call embeddedobj.ExtractFile(tmpfilename)
'create custom thumbnail
tn.quality = 90 'compress image to 90% of it’s quality
tn.width = 70 'image should be maximum 70 pixels wide
tn.height = 70 'image should be maximum 70 pixels high
tn.includefilename = False 'don’t annotate filename on image
Call tn.createthumbnailimage(tmpfilename, tmpdir + “\thumbnail.jpg”)
'attach thumbnail
Set rt = doc.getfirstitem(“Body”)
Call rt.embedobject(EMBED_ATTACHMENT, “”, tmpdir + “\thumbnail.jpg”)
'don’t process document again
doc.thumbnailcreated = “1”
'clean up
Killdir(tmpdir)
Exit Sub
errorhandler:
doc.error = "Line " + Cstr(Erl) + ": " + Error
Exit Sub
End Sub