By popular demand – scaling images in Java for Lotus Connections

After blogging about how Lotus Connetions teaches you to scale images in Java the other day I was contacted by Lotus Support who really would like to see the code as customers were asking for such code. Mitch also forwarded me a response from Lotus Support where they referred to my blog post which I got a real kick out of… ๐Ÿ™‚

So here’s the code. Thanks to the customer for allowing me to blog the code. Use to your hearts content but don’t blame me if it doesn’t work for you. The disclaimer is there for a reason.

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOError;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ScalePicture {

  public static void main(String[] args) {
    try {
      File f = new File("d:\images");
      File pictSrc = new File(f, "source_photo.jpg");
      File pictDest = new File(f, "destination_photo.jpg");
      if (pictDest.exists()) {
        System.out.println("deleting...");
        pictDest.delete();
      }

      // scale image
      BufferedImage img = scaleImage(pictSrc);

      // write to target image
      ImageIO.write(img, "jpg", pictDest);

    } catch (Throwable t) {
      t.printStackTrace();
    }
  }

  private static BufferedImage scaleImage(File source)
    throws IOException {
    // declarations
    final int width = 115;
    final int height = 115;

    // read source image
    BufferedImage imgSrc = ImageIO.read(source);

    // calculate scale factor
    double scaleFactor = (double)imgSrc.getWidth() /
      (double)width;

    // scale image
    BufferedImage imgScaled = new BufferedImage((int)
      (scaleFactor * 100), height,
      BufferedImage.TYPE_INT_RGB);
    AffineTransform transform = AffineTransform.
      getScaleInstance(scaleFactor, scaleFactor);
    Graphics2D g = imgScaled.createGraphics();
    g.drawRenderedImage(imgSrc, transform);
    g.dispose();

    // create new target image in correct size
    // with white background
    BufferedImage imgResized = new BufferedImage(width,
      height,
      BufferedImage.TYPE_INT_RGB);
    g = imgResized.createGraphics();
    g.setBackground(Color.WHITE);
    g.fillRect(0, 0, width, height);

    // calculate offset for scaled image on new image
    int xoffset = (int)((double)(width - imgScaled.getWidth()) /
      (double)2);

    // draw scaled image on new image
    g.drawImage(imgScaled, xoffset, 0, null);
    g.dispose();

    // return new image
    return imgResized;
  }

}

Allowing diagnostic data to be sent to IBM

What if the CRASH_SENDTOIBM notes.ini setting was set for all new Domino Server installations; imagine how much diagnostic information that IBM would gather that would make the product better for all of us? I know there are privacy concerns and test servers but still…

“When the Notes.INI setting CRASH_SENDTOIBM=1 is set on the server, no additional configuration is required. When the server restarts after a server crash, diagnostic information is collected and an email is sent to IBM.”

Technote 1321120: Allowing diagnostic data to be sent to IBM

Lotus Symphony in-depth product comparison white paper

Received this from a colleague today and thought I would shere. The link takes you into PartnerWorld so I guess you need an account for that to read the document. Although it says “share this paper with your prospects” I don’t know I may post an unprotected version.


Lotus Symphony in-depth product comparison white paper

This new white paper provides you and your customers with a broad, detailed comparison of Lotus Symphony 1.2, Microsoft Office 2003, 2007 and OpenOffice.org 3.0. Share this paper with your prospects so they see how Lotus Symphony is the obvious alternative to proprietary office productivity software. Available at no charge, Lotus Symphony is helping businesses control software acquisition and upgrade costs everywhere, supporting over 28 languages.

Lotus Symphony in-depth product comparison white paper

TwitNotes 1.0.10

Today I saw that suddenly TwitNotes wasn’t displaying any tweets. I could tweet and search from it just fine but the main timeline wasn’t displayed. I traced the issue to an error with the utc_offset handling in the Twitter JSON API I forked back when… I have now resolved the issue and placed a widget descriptor for TwitNotes 1.0.10 on the blog and corresponding features on the update site.

To update TwitNotes either

  • drag the widget descriptor onto your MyWidgets sidebar panel or
  • do an update installed features operation (those this solution is right for knows how)

I wish to thank those who kindly reminded me of this problem – nice to see people using it.

At Dannotes today

Today I’m at the Danish Notes User Group (Dannotes) in Korsør here in Denmark. This time there is a very interesting lineup for this two day event as Gabriella Davis from the Tutle Partnership is here to present on admin stuff and Andre Guirard from IBM is here to present on the new an exiting stuff for appdev. I actually just had a nice chat with Andre which was nice.

I’m doing, what I hope will be, an inspirational session on what’s possible in the Notes 8 client using widgets and some nice plug-ins. Should be fun.

Configuring SSO between Lotus Domino and Lotus Connections

This morning I configured single-sign-on (SSO) between Lotus Connections and Lotus Domino and was again surprised by how easy it is. The steps are simple:

  1. Open the WAS server administration interface and go to Security > Secure administration, applications, and infrastructure > Authentication mechanisms and expiration.
  2. Select “Authentication mechanisms and expiration” in the “Authentication” section on the right hand side.
  3. Now in the “Cross-cell single sign-on” section specify a set of passwords and export the keys to a file on the file system.
  4. Move the file to your local file system.
  5. Now follow the guidelines in the Domino Administrator help for importing the keys into Domino LTPA configuration.