0
votes

i'm using MFMailComposer to send an image.m using this code

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        if (picker !=nil) {
            picker.mailComposeDelegate = self;
            NSString *msgTitle;
            [picker setToRecipients:[NSArray arrayWithObjects:@"", nil]];
            [picker setSubject:msgTitle];
            [picker addAttachmentData:UIImagePNGRepresentation(imageView.image) mimeType:@"image/png" fileName:@"img"];
            [self presentModalViewController:picker animated:YES];

if my image size is 500kb in MFMailModalView image size shows 2MB.

images is to big.i am send image only in the same size as in my code.

1
Accept as a True answer if its working correctly.Kuldeep

1 Answers

1
votes
NSData *UIImageJPEGRepresentation(UIImage *image, CGFloat compressionQuality)

//Replace this snippet to your code
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
if (picker !=nil) { 
   picker.mailComposeDelegate = self; 
   NSString *msgTitle;
   [picker setToRecipients:[NSArray arrayWithObjects:@"", nil]]; 
   [picker setSubject:msgTitle];    
   [picker addAttachmentData:UIImageJPEGRepresentation(imageView.image,0.5) mimeType:@"image/png" fileName:@"img"]; 
   [self presentModalViewController:picker animated:YES];

The function will help you to compress the image in size.