NSData made from gif file reduced to less than 10kb when sending via email

209 views Asked by At

Ive got the following code that turns a gif file in the app's document folder into a NSdata object and then attaches that object to email.

In the Xcode simulator everything seems to work perfectly and adds the correct file size to the Mail window.

On iPad however the gif displays as an animated file in the mail window but the file size is less that 10kb and does not animate when opened on receiving end.

I have checked the gif file in the documents folder via iTunes file sharing and it is working perfectly. I check the Size of the data in code below and output is 6084937 for a 5.9 mb file (checked via iTunes file sharing). The mail window lists it as 4.1 kb however.

Any ideas what I am doing wrong?

Thank you : )

Code below:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];

picker.mailComposeDelegate = self;
        [picker setSubject:@"Gif file from app"];
        [picker setMessageBody:@"Mygameplan gif image" isHTML:YES];

             NSURL *documentsDirectoryURL = [[NSFileManager defaultManager]     URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
             NSURL *fileURL = [documentsDirectoryURL   URLByAppendingPathComponent:@"MyGifPlan.gif"];

             NSData *gifData = [NSData dataWithContentsOfFile:[fileURL path]];



             /////  Check size of data

             NSInteger size =  [gifData length];

             CCLOG(@" size of data %ld", (long)size);




             [picker addAttachmentData:gifData mimeType:@"image/gif" fileName:@"MyPlanGif.gif"];


             [[app navController] presentModalViewController:picker animated:YES];
0

There are 0 answers