The process by which plants and some bacteria produce organic compounds and oxygen through the absorption of light energy.