1. A non-transitory machine readable medium of a device that captures images, the medium storing a program that when executed by at least one processing unit captures an image of a high dynamic range (HDR) scene, the program comprising sets of instructions for: capturing lighting conditions of the HDR scene; capturing and storing, upon the device entering an HDR mode, a plurality of images at a first exposure level; capturing, upon receiving a command to capture the HDR scene, a first image at a second exposure level and a second image at a third exposure level; selecting a third image from the captured plurality of images at the first exposure level; and compositing the first, second, and third images to produce a composite image of the HDR scene; wherein the first exposure level, second exposure level, and third exposure level are based on the captured lighting conditions.