Menu
Active5 years, 2 months ago
I wish to reduce image size around 200KB before save into database. Let say I have a bitmap file around 39MB, I need to convert Bitmap to Jpeg and then reduce the Jpeg file <= 200KB (all type of graphics file are possible to convert (e.g bmp, jpg, png), but final graphic type will be Jpeg lesser than 200KB). I'm writing the following code try to convert (in this case i set the jpg quality to 10 since i want the file size to be 200KB):
Compress Pdf File To Less Than 100kb Free
I use the same image file to convert in Adobe Lightroom program in export dialog limit the size to 200KB and compare with the image converted by the above function BMPtoJPG. The quality image from Adobe Lightroom is much more better than the function method (both file size around 200KB)
Can anyone show me how to write code reduce image size (limit size to 200KB) while the quality doesn't drop much.
Thanks and appreciate for your answer.
Sherlyn ChewSherlyn Chew
2 Answers
If your goal is to have a smaller file content, you can first resize the bitmap, then apply a better
CompressionQuality
rate.Apr 27, 2017 Compress Image to 200 Kb. In this post I will compress the image size under 200 Kb and the same process will be done if you want to reduce jpeg file size to 20kb etc etc. Follow the following steps to reduce jpeg file size – First of all get the scanned copy of your documents in your laptop or PC on which you will work. Best Online PDF Compressor: Compress PDF to 100 KB for Free. Online2pdf Compressor is the only one online PDF compressor that can compress my 11.8MB-PDF file to 98KB. Its powerful compression capability results from different compression modes and settings to downsize a PDF as much as possible.
As a result, the global quality of the image would probably be better.
The
Arnaud BouchezArnaud BouchezTJpegImage
relies on the standard libjpeg library, whereas I suppose that Adobe has its own tuned implementation. You can try other implementations, like the one included in GDI+, or a pure pascal implementation or even old Intel's library.38.3k33 gold badges6161 silver badges137137 bronze badges
See if your encoder support sampling. If you sample your Cb and Cr components at a lower rate than the Y component, you can often get better compression with out a lot of quality loss. If you do 4:1:1 you cut the amount of data to compress nearly by a third. 2:1:1 cuts it by half.
This technique called chroma subsampling.Unfortunately, Delphi's stock
TJpegImage
wrapper around IJG implementation ver. 6b does not expose this capability and initializes encoder context to all-default values which corresponds to 4:2:0. Refer to TJPEGImage.Compress
method code, libjpeg
documentation and jpeglib.h
or JPEGLIB.PAS
from the pasjpeg
package, if you prefer (latter is merely straightforward translation of IJG implementation ver. 6a to Pascal).Also, you can migrate to the one of other implementation. In addition to @Arnaud Bouchez list, it is worth to mention yet another Pascal implementation available to reuse: http://www.colosseumbuilders.com/sourcecode
Free Consulting3,45611 gold badge2222 silver badges4545 bronze badges
user3344003user3344003
16.1k33 gold badges1717 silver badges4545 bronze badges