I could be wrong but I don't think you can. If you have them on your iMessage on iPad of Mac then you'll still have access to them but not on the phone if you do a clean install.
If you're running Windows you can always download your saved camera roll pictures by accessing your iPhone like you would an external device or hard drive.
Couldn't you go to your iCloud backup settings and disable everything except messages/photos? Then do a restore, and restore from the icloud backup with just messages/photos.
Couldn't you go to your iCloud backup settings and disable everything except messages/photos? Then do a restore, and restore from the icloud backup with just messages/photos.