Search code examples
javapythoncompressionimage-compression

Compressing in Python and decompressing in Java for data transfer


I need to compress PNG images on PC for data transmission in Python, transfer it to mobile and read it there in Java. I need lossless compression.

The hard part is compression and decompression in different environments and programming languages. I need to use something available for both languages. I've tried zlib, which technically should work, but it only decreases size by about 0.001% (with "best" compression setting 9).

  1. What am I doing wrong with zlib, if anything?
  2. What are the possible alternatives?
  3. Is there any other way to go about this problem? I just need to transfer data as byte stream and the compression was my first thought to optimizing it.

Solution

  • compressing a a compressed file (like png / jpg) will normally not yield a lot and can even occasionally increase the file size. It's not worth the effort.