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
 JPEG Quality to one MB
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

HeiniPotsdam

2 Posts

Posted - May 02 2018 :  10:37:20  Show Profile  Reply
I have several JPEG files.
I want to store them in a database.
The size of the files is very different, from 0,5 MB to 8 MB.

I want to store the files with around 1 MB.
Reducing the quality over IO.Params.JPEG_Quality.

I tried loading the files and reducing the quality step by step until 1MB is reached. A slow way.

Anybody know a better way?

Best regards, Olaf

xequte

39053 Posts

Posted - May 03 2018 :  16:55:19  Show Profile  Reply
Hi Olaf

Arbitrary limits on JPEG image size are always problematic. Because of lossy compression, guessing the final size is like asking how much red paint will I need to paint a sunset

If you must have the limit, then ensure you use a memory stream rather than saving to temp files, and use a halving process to narrow in on the optimal size. e.g. measure 60% and 80%. Assuming 60% is <1MB and 80% >1MB, then try 70%. Too small? Try 75%, etc.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

HeiniPotsdam

2 Posts

Posted - May 03 2018 :  17:45:11  Show Profile  Reply
Hi Nigel

Thank you

I've tried different file sizes now.
From this I have calculated an approximate straight line, but with a wide dispersion.
Now I get smaller files, which are often relatively close to 1 Mb.
That's enough for my purposes.

Best regards, Olaf
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: