The planetary nebulae have nothing to do with planets - the name comes from the superficial resemblance of some of them to faint planetary disks.
They are shells of gas ejected from very hot stars. These stars have masses in excess of 1.2 times the mass of the sun. Each shell contains one or two tenths of the sun's mass on average. They expand at 20 to 30 km/s.
Planetary nebulae are one of the major ways that red giant stars, nearing the final phase of their existence, eject large quantities of matter back into the interstellar medium from whence they were formed. This ejected matter is enriched in heavier elements formed within the stars.
Although only three Messier objects are planetary nebulae, over 1,000 of them are known in our galaxy.
Click on a thumbnail image to see the full size image.