How do devices encode pictures to store them?

I'm doing a study on how the iPhone 5c - or really any iPhone or like device compresses photos to store them.
Can anyone tell me how the device encodes a picture into binary (preferably)?
Like does each colour have a different binary number meaning each bit is recorded as binary in the phone?

A website link would be appreciated as well as an answer but that's just me being complicated and I'm not fazed if I don't get one.

The predominant picture format is JPEG, and is a complicated, lossy compression format.

As a first step, the colour space is translated from RGB (binary, 8 bits per colour) into Y Cr Cb - luminance, chroma red / chroma blue - various downsample modes allow the luminace to be encoded in greater detail than the colour.

JPEG is designed to work on photographic images - the hard edges of a digitally generated image or small text in an image are difficult for it to encode without artifacts