Einstein wrote the equation "E = h*(nu)", where h is the so-called "Planck's constant", and nu is the frequency of light. Translated, this means that each photon carries an amount of energy proportional to its frequency, higher-frequency photons (IR -> red -> blue -> UV -> X-ray) carry more energy.
tl;dr: Quantization is an inherent property of light.