Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compress the following image data
(05-15-2020, 02:57 AM)Madammar Wrote: i have Jpeg image that loaded into memory stream and later on i use TIdEncoderMIME To encode the stream to a base64 string 
but the output base64 string length is 4000 which is too big. is there any way to compress this string to get smaller length ?

Base64 adds overhead. The length of the string will be 1.33x times higher than the data being encoded. Which means your compressed JPG is 3000 bytes before base64 encoding is applied. If that is too high, you will just have to get it down lower. For instance, by increasing the CompressionQuality.

Why are you using base64 in the first place? Why can't you use the JPG binary instead?

(05-15-2020, 02:57 AM)Madammar Wrote: i already used zlib to compress the StringImageData

Since JPG is already compressed, compressing it again won't really do much. Not to mention the fact that you are compressing the base64 string, not the binary that was encoded to base64. Since the JPG is smaller than the base64, you should just send the binary JPG data instead.

(05-15-2020, 02:57 AM)Madammar Wrote: what is the correct way to compress the output data string ?

To not compress it at all. Seriously, it is just a waste of time and effort to compress/decompress base64. Instead, solve the issue with the JPG being too large to begin with.


Messages In This Thread
compress the following image data - by Madammar - 05-15-2020, 02:57 AM
RE: compress the following image data - by rlebeau - 05-16-2020, 11:32 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)