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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Optimizing Picture for saving to a database

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
lmiller@rescorsoft.com Posted - Jan 09 2014 : 13:34:59
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.
4   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Jan 10 2014 : 06:39:15
Yes. Correct.

William Miller
lmiller@rescorsoft.com Posted - Jan 10 2014 : 02:36:21
Thanks to both for suggestions.

@Nigel: By compression I am assuming you mean the quality (MyImage.IO.Params.JPEG_Quality). Is that correct?
xequte Posted - Jan 10 2014 : 02:27:47
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
w2m Posted - Jan 09 2014 : 16:46:08
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