Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Greetings fellow monks!

I am trying to write a script that makes thumbnails then uses a javascript to open the image in a new window. When the image is uploaded, it's height and size are recorded using Image::Info. The problem is, if the image is 100x100 (this is just an example, it does this with all size images), the thumbnail works fine but when the thumbnail is clicked the window isn't the right size. The window is always too small and ends up cutting off part of the picture.

It recognizes the image dimensions because I print them to screen, which are correct. The window just doesn't seem to be the right size though. Can anyone make a guess as to why?

Thank you!

my ( $filename, $width, $height ) = split ( /::/, $upload{$_} ); print qq(<td valign="top" width="120" height="120">), qq[<A HREF="javascript:window.open('$imagelocation', '','toolbar=no width=$width height=$height scrolling=yes'); void('');" +>],

janitored by ybiC: Retitle from "Mathematical error"

Replies are listed 'Best First'.
Re: Image dimensions don't match window size
by Roger (Parson) on Dec 16, 2003 at 02:19 UTC
    I think the window size you pass to the javascript should be slightly larger than your image size because the (*)Windows manager has to draw the borders and title bars etc within the window size you specified. And therefore the client area for drawing the image is always smaller than the size you specified.

      Even within the client area, the browser leaves margins around the picture. Both the left margin and top margin take away spaces. To make it looks nice, you probably want to add bottom margin and right margin, so that the picture is centered.

      As the sizes of the title bar, borders and margins are fixed, so it is very easy for you to calculate window sizes in your javascript:

      window_width = 2 * BORDER_SIZE + 2 * LEFT_MARGIN

      window_height = TITLE_BAR_HEIGHT + BORDER_SIZE + 2 * TOP_MARGIN

Re: Image dimensions don't match window size
by edoc (Chaplain) on Dec 16, 2003 at 02:19 UTC

    well, not exactly a Perl issue if the dimensions are printing correctly, but.. do you need to increase the dimensions to take into account the window borders etc?

    cheers,

    J