Closed DV-Anh closed 8 years ago
Could you please do this for a small image and then post the Base64 you are getting.
Sorry for the delay in response. I decided to use a different encoding method which yields desired result with UIImage
that taken directly with imageNamed
[[NSString alloc] initWithUTF8String:[[UIImagePNGRepresentation(image)base64EncodedDataWithOptions:NSDataBase64Encoding64CharacterLineLength] bytes]];
I used a 30x40 jpeg
and these are the results
Direct UIImage
:
/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAAB
AAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAHqAD
AAQAAAABAAAAKAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklN
BCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgAKAAeAwERAAIRAQMRAf/EAB8A
AAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAAB
fQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYn
KCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeI
iYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh
4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYH
CAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRC
kaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZX
WFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKz
tLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMA
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB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rcdR
u/SuCeCMywGErQq1uRtpLTW13daa9ummz6OXw3GfFGU47EYaVOK5LSbtO/M7RUWr
053SXN1jut7n/9k=
These are valid for decoding with both Java and C# even though they are different. However I right now have no means of confirming the resultant images ended up on server (ASP .NET).
I'm not sure with jpg
images since I got undesired results using them. Would large image and image format be the causes for this?
Thanks for sending this. I am also using this same technique to get user images, encode them and send to a server.
Is anyone else here seeing this type of error too?
I have decided to use another syntax
[NSString stringWithUTF8String:[[UIImagePNGRepresentation(image) base64EncodedDataWithOptions:NSDataBase64Encoding64CharacterLineLength] bytes];
The resultant strings still sometimes differ, sometimes don't. Though all results are decodable with Java and C#, and the images are seemingly identical. I guess my problem has been solved since there are no error or meaningful alteration in data encoded and decoded. Should this issue be closed?
Is the image fetched from FDTake not meant to be decoded to
NSString
via base64 encoding? This was how I did the encoding:And the decoding:
While the image can be encoded and then decoded immediately and still be shown on
UIImageView
, only ones that were create directly from stored image files can be decoded for tranference among systems. Is something wrong with images that are picked via FDTake?EDIT: I'm using XCode 6.4, iOS 8.0