1

Well this may be a very easy Question but I'm not getting the answer after searching a lot.

I have one application in which I send the image taken from camera. The path of image captured from camera is stored in database. So in mail attachment code I load image from path and attach like this:

     UIImage *myImage = [UIImage imageWithContentsOfFile:ImagePath];
     NSData *imageData = UIImagePNGRepresentation(myImage);
     [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"Spotted"];

but the image is rotated by 90 Degree left every time. Can anyone guide me what am I doing wrong here??

P.S.: NSLog of ImagePath --> /var/mobile/Applications/4BFB1BD9-DD83-42AF-A2BF-A5E4CC0DEAE3/Documents/459443.png

rohan-patel
  • 5,772
  • 5
  • 45
  • 68

2 Answers2

2

Unless you need it to be a PNG, I suggest converting it to a JPEG. JPEGs are more compressed (useful when it comes to email) and don't seem to have this rotating problem. Try using NSData *imageData = UIImageJPEGRepresentation(myImage); instead.

I've twisted my brain on this problem for several days as well. If you need it to be a PNG, here's a pretty good write up of what I learned on the topic: iOS PNG Image rotated 90 degrees

Community
  • 1
  • 1
Boeckm
  • 3,264
  • 4
  • 36
  • 41
2

There has been some discussion on the Apple site about this issue in pictures sent by mail.

Abizern
  • 146,289
  • 39
  • 203
  • 257