• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Beginner at Image manipulation...

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi all..

I wanted to see if I could get some direction on Image manipulation. I have experience in handling uploading of files and even saving to disk but have no experience in manipulating an image besides using Grails plugin called ImageTools (uses JAI) which basically does all the work for me. I am really weak in this area and hope to get some direction on a few questions..

1. Is it better to save the file to file system on the webserver and the url to the database or is it better to save the image as a byte array in the database? Industry standard? Performance benefits when served?

2. What is the Java standard for handing Images and manipulating them without affecting their quality. For instance if I wanted to be able to upload an image, then resize and crop it to be used as a thumbnail... where do I need to go to learn the BEST way of doing this? Like I mentioned, I play around with Grails, its awesome... the plugin I used is basic and I want to have complete control over this process without affecting quality.

Thanks in advance for any direction.

Mike

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mike smith-croteau wrote:1. Is it better to save the file to file system on the webserver and the url to the database or is it better to save the image as a byte array in the database? Industry standard? Performance benefits when served?



I don't know about "industry standard", but in my mind, storing large amounts of binary data in a database intended for relational data doesn't make sense. The file system offers features which allow one to duplicate some database features, for example, creating a directory for a user's uploaded images with his user id. The user id is then the "foreign key" which you can use to look up the data at a later time. One can also store metadata about the image in property files (i.e. a title or caption for the image).
As for your other questions, let's move the conversation over to the GUI forum.
 
mike smith-croteau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! I have saved to file system in previous applications and seems to be a good way to do it. I was able to create directories specific to users or other defining characteristics which made managing manually easy as well too. I wasnt sure about saving to database but every now and then I come across a development article which shows saving image as byte array... so always left me wondering if there was a performance advantage or something. Do you know of any advantages to saving to database?

Thanks again. BTW, I was google searching for wrong terms as far as image resizing etc.... found some good articles already.

http://www.componenthouse.com/article-20/page2

which led me here:

http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html

if anyone has any others.. would love to see.

Viva!
Mike
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mike smith-croteau wrote: I wasnt sure about saving to database but every now and then I come across a development article which shows saving image as byte array...



Development articles are often demonstrating useful functionality (storing binary data in a database) at the expense of Best Practices (do we REALLY want to do that?).

mike smith-croteau wrote:
so always left me wondering if there was a performance advantage or something. Do you know of any advantages to saving to database?



I have not done any benchmarking, so take my opinion for what you paid for it: if one loads a file from the file system, the overhead is finding where the file is opening it and reading it. If one loads from the database, there is the overhead of making or getting a database connection, creating and executing a query, locating the image in a table (which is usually stored on disk), reading it into memory if necessary and transferring it across the database connection. In my mind, file system wins.
There would have to be some very important requirement to get me to store an image in a database (associating metadata with the image that would be too complex for a property file, for example). And even then, I'd probably store the metadata in the database and the image on the filesystem.
 
mike smith-croteau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:
I have not done any benchmarking, so take my opinion for what you paid for it: if one loads a file from the file system, the overhead is finding where the file is opening it and reading it. If one loads from the database, there is the overhead of making or getting a database connection, creating and executing a query, locating the image in a table (which is usually stored on disk), reading it into memory if necessary and transferring it across the database connection. In my mind, file system wins.
There would have to be some very important requirement to get me to store an image in a database (associating metadata with the image that would be too complex for a property file, for example). And even then, I'd probably store the metadata in the database and the image on the filesystem.



Awesome explanation! Thanks Joe! Thinking about it this way makes so much sense.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic