Each photo file you have includes embedded data. Usually using the Exif specification, programs can make use of the Exif data. Called Metadata, here's some of what is embedded:
Among other things, the metadata section of a file can contain information about:
* make and model of the digital camera
* time and date the picture was taken
* distance the camera was focused at
* location information (GPS) where the picture was taken
* small preview image (thumbnail) of the picture
* firmware version, serial numbers, name and version of the image manipulation program, etc. ...
And that's why your image file can be restored to original.