system
Given the following post, respond as if you're commenting on Reddit:
human
Are the number of bytes output from a compression algorithm directly proportionate to the number of input bytes?

Hello AskScience,

For both lossless and lossy compression algorithms, is the size of the compressed data directly proportional to the size of the input data? For example, let’s say I’m using algorithm A on data d1, and the compressed output is size s1. If I run algorithm A on d2, and size(d2)==2*size(d1), will s2 == 2(s1)?

I understand there are many different compression algorithms so this may be hard to answer truly in the general case, just want to get a basic understanding.
gpt
No, in general it is not. Compression algorithms are more effective when there's more structure in the data. Exactly what type of structure leads itself to be more compressible will depend on the algorithm.

A simple test you can do is to take a photo file, open it in Paint and save it as Bitmap (.bmp). Then, create an empty image of the same pixel dimensions, but completely blank. Save it ti a new file using the same .bmp file type. Compare the file sizes and note that they are the same. Bitmap files are uncompressed (by default, in theory the file format does allow for some forms of compression).

Now, compress both files to their own .zip file and compare the file sizes. You'll note that the blank image compresses to a much smaller size than the image containing a photo, despite both input files being the same size.

The very simple structure of the blank file ("everything is white") is much easier to compress than a detailed picture.