-2

I have a system using jsf and prime faces and there is a upload image function and I need to generate thumbnails for this image, I found many ways on internet but none meet my requirements.

Actually I would like something like facebook avatar where we can resize and move the picture to fit into a blank square.

Requirements:

  • Can be on image upload page using query, prime faces, etc...
  • Can be on java side after image upload
  • Can not crop image
  • Must keep ratio
  • Can add white, or transparent (better) area around the image if it is not square to make it square

I found some css or php examples but not for JAVA.

Thanks

Gnoupi
  • 4,715
  • 5
  • 34
  • 50
Igor
  • 91
  • 1
  • 12
  • 3
    *"Requirements:..."* - are you giving us a BRD? – Alex Salauyou Apr 14 '15 at 13:54
  • Sash of course not, I am searching tools, libraries or techniques to do it. It should be also good for other users as it is not a uncommon task. Please review down vote. – Igor Apr 14 '15 at 15:31
  • Asking for libraries, tools etc is also off topic here :( – Alex Salauyou Apr 14 '15 at 17:49
  • Yes ? Are you sure that I can not ask for a library ? Where is this rule ? But looks like that be rude is ok as we can see in your firs answer that was very helpful and related to this topic. Thanks guy ! – Igor Apr 15 '15 at 02:41
  • http://stackoverflow.com/help/on-topic #4. – Alex Salauyou Apr 15 '15 at 07:30
  • BTW, if you slightly modify the code of resource @Juraj gave you, you can make it serve your particular requirements. It is not so complicated. Good luck! – Alex Salauyou Apr 15 '15 at 07:37

1 Answers1

1

ImgScalr can achieve these tasks and is simple to use.

Juraj
  • 161
  • 1
  • 2
  • 11
  • Sounds very good but I still could not find the function that I need. I tried BufferedImage thumbnail = Scalr.resize(imBuff, 100, 100, Scalr.OP_ANTIALIAS); but my thumbnail get 100X56 and I need 100x100 can white borders on the bigger side. – Igor Apr 14 '15 at 16:04
  • Thanks guy, you have my up vote. This lib do not fit all my needs but it is already helpful. – Igor Apr 15 '15 at 02:42
  • Sorry, I haven't clearly understood, but now for what you want, library described in [another question](http://stackoverflow.com/questions/8150276/what-java-library-should-i-use-for-image-cropping-letterboxing?rq=1) seems to be even better for your needs. – Juraj Apr 15 '15 at 12:18