Weird cfimage rotate issue

Hi all,

this is a strange one and Im not sure if anyone will be able to help but I have hit a brick wall!

I have written a little script for a site im working on where by you can email a picture to a designated email and using a scheduled task the server checks the inbox every 5 minutes to see if there is an email. If there is it downloads the attachment and then using some basic cfimage stuff it takes the image, thumnails it and stores it and some info in the db. this all works perfectly at the moment using cfpop.

All good. and for 90% of emails it works fine. However if i use my iphone 4 and send a picture in portrait mode the image always seems to come through rotated 90 degrees to the right. landscape ones are fine. its really irritating as i have no idea why it is happening - does anyone have any ideas why it might be happening or better yet any ideas how i can work around it?

I have checked the raw image downloaded using cfpop and this is rotated 90 degrees to the left - so its not the cfimage causing the isse

Any help, as always, is hugely appreciated.