Best Aspect Ratio Compression in Python?

Which compression method in Python has the best compression ratio?

Is the zlib.compress()best used usually or are there some better options? I need to get the best compression ratio.

I collect strings and send them via UDP. A typical string I compress is about 1,700,000 bytes.

+5
source share
3 answers

I'm sure there may be some more obscure formats with better compression, but lzma is the best of those that are well supported. There are some python bindings here .

EDIT

Do not choose a format without testing, some algorithms work better depending on the data set.

+6

, bz2 , gz (zlib).

, xz (LZMA2), , , , python.

Python Doc BZ2

: . , raw, bmp uncompressed tiff. .

EDIT2: . Image Magick python .

+3

, . , ( ), , , (. ). ).

, (.. ), . . .

I would search through PIL to see what I can use. Something like converting an image to JPEG with a compression ratio compatible with the quality under study should be very effective before sending.

You should also be very careful if using UDP, it may lose some packets, and most compression formats are very sensitive to missing parts of the file. OK. This can be controlled at the application level.

+1
source

All Articles