IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

measuring an imageAt Lotusphere, someone asked me how to take an image file and use LotusScript to determine the dimensions (in pixels) of the image it contains. I thought I already had code for this, and using the Design Element Search tool I wrote about previously, I was able to find it. It's in an example database from Lotusphere 2006, which if you're interested, you can download from the Lotus developerWorks Sandbox. It's in the script library Class ImageResourceImporter, method CalculateImageSize. Since this is a class method, not a stand-alone function, it doesn't actually take any arguments or return any values; it just operates on the object properties. (The comment in the method is incorrect in describing the return value -- that comment was left over from an earlier version where it was a standalone function). It shouldn't be too difficult to adapt it back to standalone use, if that's what you need.

Regrettably, it only works on GIF and JPEG files -- perhaps someone can point us to a more general algorithm online somewhere?

This routine is a good illustration also of how you can use the NotesStream class to pull binary information from a file and do math with it. Of course, it's nicer if you can feed a series of bytes into a structure and manipulate it as words and doubles and so on, but this is not an option for data read from a file (unless someone knows a trick I haven't seen?), and even if it were, different operating systems represent values differently, internally.

Andre Guirard | 28 January 2008 10:42:02 AM ET | Plymouth, MN, USA | Comments (1)


 Comments

1) Thanks! - Works great!
John Dillon | 1/30/2008 10:01:56 PM

Thank you for the code. It's very helpful and I got it working right away.

I really enjoyed your sessions at Lotusphere this year.

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact