Data is irretrievably lost during compression. Example sof this might be reducing the 'resolution' of an image by changing the colour depth, normally with the aim that the human eye or ear cannot detect the compression which has happened. Another example might be a sound file having its resolution reduced whereby the human ear cannot detect the change, but significantly reducing the file size.
No data is lost during compression. Packed and unpacked at each end...
- Huffman compression - An analysis of the text to be sent is analysed for the most commonly used characters, where possible the bit codes are shortened for these characters (where code comparison cant produce matching errors). Data is then packed into a BITSTREAM of shortened character codes where most commonly used characters bit-code is substituted for the compressed version. At the other end the data is repacked using the same algorithm. Data is then compressed during transit only.
- Run-length encoding - (This is particularly useful for bitmap images) Sequences of the same bit pattern are identified within the image. A code is then created which defined the bit pattern and exactly where it occurs in the file.
https://computer.howstuffworks.com/file-compression.htm