0

I am currently developing a website in which several images will be displayed on a single page. In light of performance, I'm searching for the best way to handle thes images.

First, I will explain my needs. The back-end of the website consists of a CMS in which images can be uploaded (and maybe resized by the user so the image will have the neede ratio of width/height). These images will be displayed on several pages in de website, requested by (hopefully) many users.

Secondly, I will shortly describe my environment. I am developing in Java EE, using JSF as front-end. I am using multiple libraries like Prime Faces et cetera.

I have done some research and it seems there are dozens of solutions, but I don't know in which direction to search. E.g.:

  • Saving images in database
  • Saving images as static images by using for example filestreams

So in short:

  • Which way of saving and requesting images would be best in this case?
  • What library would you advice to serve me in this?
  • Is there a JSF-solution to manually resize images?
  • Would ImageJ be the best solution to generate thumbnails? If not, what would be?

If any other details are needed, I'm happy to provide them. Thanks in advance.

Menno
  • 12,175
  • 14
  • 56
  • 88
  • 1
    JSF will help you generating HTML to the client and will facilitate the request handling. The way you decide to save/request your images would be reflected in the requests made by JSF (like a plain Servlet make a request). For more info about image handling in web applications, see [Store pictures as files or in the database for a web app?](http://stackoverflow.com/q/561447/1065197). Note that the solutions offered could talk about .net or other platforms, so keep with the main concepts: web application, request handling, save in disk/filestream, these concepts can be implemented in Java/JSF. – Luiggi Mendoza Nov 19 '12 at 16:53

2 Answers2

0

I wouldn't worry about performance until it becomes an issue. I would perhaps worry more about auditability, maintainability etc.

In order to make a future change easy, however, is abstract away your image store such that you can easily replace (say) a file-based system, with a database system (or a cloud-storage solution, or, or...).

That way you can easily substitute one for another and compare/constrast if need be, or simple swap out your implementation at a later date.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
0

So..

  • Saving images as files is best
  • After some research it seems that PrimeFaces offers ImageCropper
  • File Upload can be achieved using PrimeFaces' FileUpload

But still, I have seen many discussions on Image Manipulation by Java and the best tooling for this. Some say ImageJ would be great, others don't. Is there any reason why I should go with one or another?

Menno
  • 12,175
  • 14
  • 56
  • 88
  • 1
    I don't know if someone would give you a good answer on this. The best will be to make proof of concepts with ImageJ and other libraries to make up your mind about this. – Luiggi Mendoza Nov 19 '12 at 18:52
  • Hmm maybe you're right. Just like other discussions on the internet there may not be a 'best' answer. At least now I know that saving images as files is best, instead of clogging the database with them. – Menno Nov 20 '12 at 07:35