Author: BjornOhlsson | Posted on: 5/30/2009 4:10:07 AM | Views : 1209

 Hello, I wonder if it is possible to compress an image in code not only to a specific size in pixel but also to a given size in bytes.
Let say I would like to save uploaded images to size 500x376 pixel and also compress them to size 50kB (given that they of course has at least these sizes).  I know how to save to a specific width and height with GetThumbnailImage and I have found EncoderParameter to use to compress the images. But there, if I understand it right, you compress to different qualities between 0 and 100, not to a given size in bytes.
Of course I guess one change the quality in a loop until the image reaches a specific size, but how do I found the size in bytes of an image in C#. 

 
...

Go to the complete details ...