aspose file tools*
The moose likes Servlets and the fly likes Creating Image Thumbnails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Creating Image Thumbnails" Watch "Creating Image Thumbnails" New topic
Author

Creating Image Thumbnails

matt eggbeers
Greenhorn

Joined: Mar 11, 2005
Posts: 14
Hello All,
I have a file server that has all my picture for an application (user uploaded) and I have created a servlet that gets them from the file server and returns an array of bytes with the MIME type image. It all works great, but is kinda slow because the images are like 2500x2500 pixles, and in some cases the user is viewing 50+ of them.

I was wondering if there was a good way to scale the images (using the array of bytes) in the servlet and then pass it a parameter as to which image to get, large or thumb.

I have coded the solution below, but it is slower than the original I think... Any help would be great.
Thanks,
Matt



Also, does this solution require that the server have a graphics card because it is dealing with the Graphics object?
[ October 24, 2005: Message edited by: matt eggbeers ]
James Clinton
Ranch Hand

Joined: Jun 23, 2003
Posts: 190
- Your user is viewing 50+ images at once? I would ask myself here if this functional requirement needs reviewing.

If you unable to speed things up, I would employ a design pattern called Value List Handler:

http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html

- Another option is for each image, store a full size and a thumb. Then you don't need this resizing logic in the download request. It might seems less elegant that dynamcally resizing on demand - but perforamnce here is the critical factor.

Hope this helps.
[ October 25, 2005: Message edited by: James Clinton ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I agree in part, as the file is uploaded, crate the thumbnail and save it at the same time. Thumbnails are small and disk space is cheap
I don't like the idea of doing this in Java though, there are applications that handle scaling much better.

Also, does this solution require that the server have a graphics card because it is dealing with the Graphics object?
Nope, but you may want to search the Servlet forum for the word 'headless' to see the solution to some of the problems you'll run into, and their solutions. (headless refers to a Lunix box installed without a graphical interface)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating Image Thumbnails