ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Optimizing Picture for saving to a database
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

lmiller@rescorsoft.com

USA
3 Posts

Posted - Jan 09 2014 :  13:34:59  Show Profile  Reply
I am not really a graphics person and would appreciate some general help. I have a database application, with a table of people and would like to store a picture of each person. My users have little computer experience and will typically just take a picture of the person with their phone or small camera. I want to save that picture to my database.

I have all that functionality working but I would like to optimize, i.e. reduce the size of the picture. The quality is not critical, it just needs to be good enough to display along with the other information I am tracking.

I am assuming that JPEG is the best format for my purposes. For my purposes reducing the size of each picture 10K is not that critical. However, reducing each picture from 1MB to 200K is worth while. Currently I am adjusting the size with the following:

var
MyImage: TImageEnView;
....

MyImage.IO.Params.JPEG_Progressive := True;
MyImage.IO.Params.JPEG_Smooth := 50;
MyImage.IO.Params.JPEG_Quality := 80;
MyImage.IO.Params.JPEG_ColorSpace := ioJPEG_YCbCr;
MyImage.Proc.Resample( 1024, 1024, rfNone, True );

I would appreciate any suggestions anyone might have. TIA.

w2m

USA
1990 Posts

Posted - Jan 09 2014 :  16:46:08  Show Profile  Reply
I am not an expert about minimizing picture sizes, but I do have a few suggestions:

QUALITY
The JPEG quality setting controls the amount of file compression. The lower the number the smaller the file size. If image quality is important to you, generally don’t use a setting below 70/100, yet often lower values may still be acceptable.

PROGRESSIVE
The Progressive option changes the way the file loads – with progressive checked the image will be blurry when it first loads then become clearer. Non-progressive images load line-by-line. Progressive jpeg images are marginally larger than non-progressive JPEG's.

WIDTH AND HEIGHT
Reducing the width and height of the picture usually reduces the file size the most.

DPI
Reducing the DPI is probably the second most valuable to reduce the size of a picture. Most computer screens have a native DPI of 96 pixels per inch, For viewing a DPI of 72 to 96 DPI produce similar quality on the screen as a 300 dpi picture, but the lower DPI values help to reduce file size and memory constraints, yet still produce a quality of higher DPI pictures when viewed on screen.

PRINTING
If your users are going to print the pictures then keep the original DPI values to maximize the quality of the printed image.

So... what does this all mean for ImageEn and displaying pictures on screen and storing images in a database.

To minimize the file size:
a. reduce the image dimensions by resampling the image to the smallest acceptable size.
b. change the DPI to match the screen (96) or even slightly less (72).
c. reduce the JPEG quality.
d. Set JPEG_Smooth value to further increase JPEG Compression.
The smoothing factor for the JPEG. Range is 0 (No smoothing) to 100 is (max). If JPEG_Smooth is not zero, the JPEG compressor smooth's the image before compressing it. This improves the level of compression.

ALTERNATIVE TO STORING PICTURES IN A DATABASE
Storing pictures in a database file can and often does, result in a very large database file. An alternative to storing pictures in a database is to store the paths to the images in a string field and save the pictures to a folder that the database filename points to. This minimizes the size of the database file, yet keeps all the images in one folder.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

xequte

39061 Posts

Posted - Jan 10 2014 :  02:27:47  Show Profile  Reply
Hi

You seem to be covering the main bases. JPEG is probably the best format for compressing photographs. The main factor is the dimensions of the image, so reducing it (resampling) to the size that it need to be displayed at will give you your most gain.

Next is the compression (Quality), which can probably go as low as 70 without significantly degrading the image. Finally is the smoothing, which I tend not to favour, but can be useful.

Basically you should try these different options until you find the compromise that best suits your needs and eyeballs.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

lmiller@rescorsoft.com

USA
3 Posts

Posted - Jan 10 2014 :  02:36:21  Show Profile  Reply
Thanks to both for suggestions.

@Nigel: By compression I am assuming you mean the quality (MyImage.IO.Params.JPEG_Quality). Is that correct?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jan 10 2014 :  06:39:15  Show Profile  Reply
Yes. Correct.

William Miller
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: