An electronic device comprising: a display; a camera arranged on one surface of the electronic device; a sensor circuit configured to sense movement of the electronic device; a processor functionally coupled to the camera and the sensor circuit; and a memory electrically coupled to the processor, wherein the memory stores instructions that, when executed, cause the processor to: execute a preview mode including outputting an image obtained using the camera to the display, obtain movement information using the sensor circuit while executing the preview mode, determine whether a movement distance of the electronic device is equal to or greater than a prespecified reference distance, based on the movement information while executing the preview mode; when the movement distance is equal to or greater than the prespecified reference distance, determine whether a moving direction of the electronic device matches a prespecified reference direction based on the movement information while executing the preview mode; detect a change in an angle of the electronic device during the movement based on the movement information; in the preview mode, store first images in the memory, the first images obtained using the camera while tracking the movement distance; when the movement distance is equal to or greater than the prespecified reference distance, and when the moving direction of the electronic device matches the prespecified reference direction and when the change in the angle is within a prespecified reference range of angle changes, switch from the preview mode to a panorama capture mode; in the panorama capture mode, store second images obtained using the camera in the memory; display a preview panoramic image including a first area generated by using the first images, a second area generated by using the second images and an editing object for selecting one or more images to be used for generating the panoramic image from among the first images and displayed as a line formed on a starting position of the preview panoramic image and configured to be dragged and moved by a user so as to exclude, from the panoramic image, previous images in the area in which the moved editing object is located among the plurality of images forming the panoramic image; and generate the panoramic image based on the preview panoramic image. a display; a camera arranged on one surface of the electronic device; a sensor circuit configured to sense movement of the electronic device; a processor functionally coupled to the camera and the sensor circuit; and a memory electrically coupled to the processor, wherein the memory stores instructions that, when executed, cause the processor to: execute a preview mode including outputting an image obtained using the camera to the display, obtain movement information using the sensor circuit while executing the preview mode, determine whether a movement distance of the electronic device is equal to or greater than a prespecified reference distance, based on the movement information while executing the preview mode; when the movement distance is equal to or greater than the prespecified reference distance, determine whether a moving direction of the electronic device matches a prespecified reference direction based on the movement information while executing the preview mode; execute a preview mode including outputting an image obtained using the camera to the display, obtain movement information using the sensor circuit while executing the preview mode, determine whether a movement distance of the electronic device is equal to or greater than a prespecified reference distance, based on the movement information while executing the preview mode; when the movement distance is equal to or greater than the prespecified reference distance, determine whether a moving direction of the electronic device matches a prespecified reference direction based on the movement information while executing the preview mode; detect a change in an angle of the electronic device during the movement based on the movement information; in the preview mode, store first images in the memory, the first images obtained using the camera while tracking the movement distance; when the movement distance is equal to or greater than the prespecified reference distance, and when the moving direction of the electronic device matches the prespecified reference direction and when the change in the angle is within a prespecified reference range of angle changes, switch from the preview mode to a panorama capture mode; in the panorama capture mode, store second images obtained using the camera in the memory; display a preview panoramic image including a first area generated by using the first images, a second area generated by using the second images and an editing object for selecting one or more images to be used for generating the panoramic image from among the first images and displayed as a line formed on a starting position of the preview panoramic image and configured to be dragged and moved by a user so as to exclude, from the panoramic image, previous images in the area in which the moved editing object is located among the plurality of images forming the panoramic image; and generate the panoramic image based on the preview panoramic image.