Joan Rivers’ personal doctor snapped a selfie while the comedian was under ­anesthesia and the physician was about to perform an unauthorized biopsy that led to her fatal cardiac arrest, a report said Tuesday.

The doctor took the photo in the procedure room at Manhattan’s Yorkville Endoscopy before performing the procedure on Rivers’ vocal cords, according to CNN.

A staffer at the clinic told investigators about the doctor’s behavior, the cable-TV network said.

Rivers was at the clinic for an endoscopy to be performed by gastroenterologist Dr. Lawrence Cohen.

Cohen and the clinic’s medical director finished their work on Rivers before her unidentified personal physician took it upon himself to perform the biopsy, CNN said.

But before performing the unauthorized procedure, the doctor allegedly pulled out his camera to snap a picture of himself with the legendary star while she was unconscious, according to the network.

It was during the biopsy that Rivers suddenly went into cardiac arrest.

Investigators believe that her vocal cords began to swell during the biopsy on Aug. 29 and the flow of oxygen to her lungs was cut off, CNN said.

She died a week later.