0

I try to convert my png image to base64 string.
But I use my output base64 string in consolog and paste to online tool website.
It just show the top of image, not complete image.

image

What's wrong with my code?

UIImage *uiImageInstance = [[UIImage alloc] initWithContentsOfFile: filePath];
NSData *data = UIImagePNGRepresentation(uiImageInstance);
NSString *base64Str = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

NSLog(@"base64Str : %@", base64Str);
Beginnerrrrrr
  • 537
  • 1
  • 8
  • 27

1 Answers1

1

Use this code:

NSData *imageData = UIImagePNGRepresentation(image);
NSString * base64String = [imageData base64EncodedStringWithOptions:0];

Hope this helps.