记录一个小功能
app传base64位上去,服务器拿到后转图片保存,当app请求拿回用户图片时,服务器再把图片转base64字符串返回给app,app再转图片
// 64base字符串转图片
- (UIImage *)stringToImage:(NSString *)str {
NSData * imageData =[[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *photo = [UIImage imageWithData:imageData ];
return photo;
}
// 图片转64base字符串
- (NSString *)imageToString:(UIImage *)image {
NSData *imagedata = UIImagePNGRepresentation(image);
NSString *image64 = [imagedata base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
return image64;
}
http://picbase64.com/
http://tool.css-js.com/base64.html