No immediate help I realize, but there are a few things to be aware of in the future...
1. The S4 has SD card support. Granted, not all Android phones have this, but since the S4 does, you can always choose to save pics to the SD card rather than internal storage. (SD card is *not* wiped during factory reset)
2. Both Dropbox and Google+ offer means to automatically backup your pictures (as well as possibly other online storage services). I suggest setting then up and using them, that way you always have a second copy of all your pictures even if your phone is lost, stolen, broken, factory reset, etc...