0

I have an application where users can upload images.

This images are usually taken directly from cameras and in 1mb sizes or more.

May I know what is the standard way of compressing this images before saving them to database as BLOB?

The images stored in database are just for viewing, there is no requirement to edit the image.

I have read this:

Compress Image before Saving to disk in Java

But I am wondering there are more standard ways so that the system can be more maintainable.

some codes and links will be greatly appreciated +1

Community
  • 1
  • 1
user4127
  • 2,397
  • 6
  • 21
  • 32
  • A tip: I saved uncompressed. However I split the file into several parts (4 kb + / -). This helps in recovery. It is less expensive to load 1000 parts of 4kb than 1 part 4000kb – Falci Sep 18 '13 at 14:44
  • They are usually compressed with JPG and saved in JPG format. – Alvaro Sep 18 '13 at 14:45
  • @Falci That is interesting, care to explain a bit more? – user4127 Sep 18 '13 at 14:53
  • @Falci you are splitting an image in 1000 parts/tiles? – A. Wolff Sep 18 '13 at 14:54
  • You need to specify your requirements; will users accept modification of their original images? The suggestion from the question you linked doesn't apply to your case; saving a JPEG picture taken with a digital camera as PNG will almost always increase the filesize. – kryger Sep 18 '13 at 15:27
  • If you can get away with this, you can reduce JPEG quality (i.e. increase compression) and/or reduce image's size. There are dedicated image processing libraries (JMagick, etc.), you could also use "raw" Java (for example `javax.imageio.ImageWriter`) – kryger Sep 18 '13 at 15:45
  • This technique of splitting the file into parts we use for all files uploaded to the system. Including PDF with more than 100mb. Each line of the result of a query is atomic. The db can perform two queries at the same time with multiple rows of results, but can not run two queries with a single large result in each. It will do one at a time – Falci Sep 18 '13 at 17:40
  • I wouldn't save images as a blob in a database. Your images are served way faster as static content. – Bart Sep 18 '13 at 18:54
  • I will agree on the static content but user requirement is to save on db – user4127 Sep 18 '13 at 23:56

0 Answers0