If you need to reset your iPhone to factory settings to resolve an issue, you can back it up to iCloud first and then restore it to keep your data.
You can recover deleted photos on iPhone from the Recently Deleted folder in the Photos app or a backup on iCloud, iTunes, or ...