Closed pekpon closed 10 years ago
Can you share your code and post the full output log? It would be easier to debug if I can take a look at what you're working with.
Yes!
Now i'm not getting errors but the image isn't showing. I'm trying to do this. Encode the image from an UIIMage to webP, encode to base64 and send the image to the server. Later im getting the base64, decoding it to NSData, saving the file into the filesystem and trying to show the decoded webP image.
The code:
Encoding
The encoding code is correct because i'm sending webP image to the server and I can read this image from an Android webP decoder
Decoding
NSData *file = [self base64DataFromString: data ];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths firstObject];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"photo.webp"];
[file writeToFile:path atomically:YES];
[UIImage imageFromWebP:path completionBlock:^(UIImage *result) {
self.imageView.image = result;
}failureBlock:^(NSError *error) {
NSLog(@"%@", error.localizedDescription);
}];
Info
xCode 5
iOS 7
Decoder Version 0.4.0
Do you know what can I do? Thanks!
Since iOS7, base64 encoding and decoding has been built into Xcode. Give this piece of code a try:
NSData *base64Data = [[NSData alloc] initWithBase64EncodedString:data options:0];
if (base64Data) {
NSLog(@"Valid Base64");
}
else {
NSLog(@"Invalid Base64");
}
No result...the base64 is valid but the image isn't displayed...
This might be a stupid question, but did you write the base64 data to file?
[base64Data writeToFile:webPPath atomically:YES]
Yes, the base64 is saved to file. Dont worry! I will use webP in the future ;)
Hello!
I'm having this error when I'm trying to decode my NSData:
I cant decode my image... :(