The invention discloses a method for obtaining an image. The method is applied to an electronic device. The electronic device comprises an image collecting unit which can rotate by 360 degrees. The method comprises the steps that a first triggering instruction is obtained, and the first triggering instruction is used for representing the operation of obtaining a panoramic image of the scene where the electronic device is located currently; in response to the first triggering instruction, the image collecting unit is controlled to rotate, and N images are collected and obtained in the rotating process of the image collecting unit; the panoramic image is generated through the N images. The invention further discloses the electronic device. By means of the method for obtaining the image and the electronic device, the 360-degree panoramic image of the electronic device is more conveniently shot with the better effect.