T O P I C R E V I E W |
HeiniPotsdam |
Posted - May 02 2018 : 10:37:20 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 |
2 L A T E S T R E P L I E S (Newest First) |
HeiniPotsdam |
Posted - May 03 2018 : 17:45:11 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 |
xequte |
Posted - May 03 2018 : 16:55:19 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
|
|
|