A file format specifies how a binary string is interpreted: field order, field widths, permitted values and where decoding stops. A data compression comparison must include all fields required to recover the data.
A file header is leading information describing how to interpret the following data. Dimensions and a choice of compression method are examples. The two toy image compression examples explicitly count these fields.