Plants algae and bacteria capture sunlight after capturing they use metabolism to convert them in to energy. They do this when electrons get excited and jump off chloroplast into thylakoid membrane, the electrons have to be replaced so they steal them from CO2 and all that is left is oxygen and they release it.