Justin Maki, Engineering Camera Team lead at NASA explains how curiosity rover takes self-portrait. The question how Rover takes its selfie was answered as part of curiosity rover report on YouTube where series of questions are answered.
The rover has two meet long robotic arm which helps take its own picture. The rover can place the cameras out in front of itself and high above the rover deck to take the picture.
Justin Maki explain the video, “The self-portrait appears as though it’s taken from a single wide angle lens camera out in front of the rover but it’s actually a series of individual images stitched together”
The gif animation shows the rover is imaging the deck while the arm is behind the camera and then to image the ground and the terrain. In both the cases the arm is behind the camera and later when the images are stitched together you don’t see the arm in any of the picture.
Video on YouTube,