content: Half right...leaves do produce oxygen; specifically in the Chloroplasts of cells - primarily 'Palisade Mesophyll' cells just below the surface of the leaf. However these oxygen molecules are only produced as a by-product of photosynthesis. In Short: This oxygen is released by using energy from sunlight to split water molecules - when these are split you are left with said oxygen and two hydrogen molecules (H2O) which are no longer bound to it...the hydrogen is the important part as, in short, it holds the energy absorbed from the sunlight and can then be used by the chloroplasts to (indirectly) synthesise carbohydrates - which serve as long term energy storage.  Long story: The internal structure the Chloroplast organelle is full of folded (disk shaped) membranes known as Thylakoid(s). Complex protein structures known as photosystems (types I & II) sit on this membrane and contain the chemical Chlorophyll, when high energy photons from sunlight reach these proteins, they hit the chlorophyll molecules, and in doing so excite them. In photosystem I, eventually enough energy builds up that it is able to catalyse the splitting of a water molecule; in doing this you get a single Oxygen atom (which will 'look' to react with  another O, to form O2) and 2 Hydrogen atoms - however part of the reaction involves ionising these hydrogen atoms by removing each of their electrons (e-), in doing this they become hydrogen ions (H+) and are highly reactive. The loose electrons travel through a series of integral proteins known as the 'electron transport chain', eventually they arrive at a photosystem II protein, which once again uses Chlorophyll molecules to absorb energy from incoming photons. This time however the absorbed energy is used to excite the electrons further - by this point the electrons are highly polarized and contain enough energy that two of them together are able to cause a H+ (from outside the Thylakoid) to react with a NADP+ molecule, the electrons join with the product of this reaction - NADPH...these are then used by the chloroplasts to produce the carbohydrate Glucose in what's known as the 'Calvin Cycle' - which is how plants absorb CO2. Meanwhile the H+ ions created from photosystem I are used as an energy source to phosphorylate an ADP (adenosine DI phosphate) into an (adenosine TRI phosphate) molecule - THE ENERGY SOURCE OF JUST ABOUT EVERY CHEMICAL REACTION IN LIVING ORGANISMS.  As a footnote, I definitely need to get out more - and I hope that wasn't too long winded or insultingly obvious!