Item13029: convert inline images to attachments

also:
- added rotate param
- some code cleanup