I am downloading image from UIWebView with this method
NSURL *imgUrl=[[NSURL alloc] initWithString:[[DataPassing sharedManager] pageIMGurl]];
NSData *imgData = [NSData dataWithContentsOfURL:imgUrl];
UIImage *img = [UIImage imageWithData:imgData];
now I want to send this downloaded or saved or data Image with email using MFMailComposeViewController
NSData *imageData = UIImagePNGRepresentation(image);
[mailer addAttachmentData:img mimeType:@"image/png" fileName:@"mobiletutsImage"];
Now issue comes that I don’t know the type of downloaded image in ‘img’, so i can put rite mimeType:@”image/png”. What if the downloaded image is jpeg?
how to store multiple mimetypes and check with “img” and then send.
There is no need to worry about the image type.
UIImagePNGRepresentationreturns the png representation of theUIImageobject.If you use
UIImageJPEGRepresentationmethod to convert yourUIImageintoNSData, you should pass @”image/jpg” as mime type.One more way is in the url, the last component will be image name. Fetch the extension of it and you will come to know the mime type.