UIImage Base64 encoding fails
i'm trying to convert a UIImage which comes from the iPhones photo library to a base64 encoded string. My problem is that the output of the base64 encoded string does not match a base64 string which i've created on a online base64 encoder for jpegs.
Here is my code:
NSData *myAttachment = UIImageJPEGRepresentation(myImage, 1.0);
NSString *base64encodedAttachment = [attachment base64EncodingWithLineLenght:76];
While "attachment" is a string which wil开发者_Python百科l be part of an url request. Why does the base64 code not match the "normal" from encoding websites encoding? Is there something special about UIImage oder NSData?
Cheers
It may happen that the UIImage
is re-encoded when you call UIImageJPEGRepresentation
and therefore it is not identical to the JPEG image you have uploaded to that online site. If you want to be 100% sure that the base64 encoder works as expected, save the JPEG representation that comes out of UIImageJPEGRepresentation
to a JPEG file and upload that file to the online tool to obtain the base64 representation to compare your output with.
If you are trying to use this jpeg
file in the messageBody of the mailComposer.. then i must clear you buddy...
You cannot use the local images inside the mailbody of mailComposer, the image shud be available on the server and used in the mailbody by passing url
of the same..
If you're trying something else...i would say follow "Tamas" :)
精彩评论