• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Creating Image Thumbnails

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- 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 ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
reply
    Bookmark Topic Watch Topic
  • New Topic