Convert data from URL into Image in iPhone - objective-c

Here I'm working for static URL.
My Code :
NSURL *url = [[NSURL alloc] initWithString:#"http://cns.bu.edu/~lgrady/diagonal_line_nobreak_seg.jpg"];
NSData *myData = [NSData dataWithContentsOfURL:url];
img.image = [UIImage imageWithData:myData];
So, I can see image in ImageView.
But, While passing internal web-service URL.
And I'm getting data for Image in bytes from url instead of Image like below:
{"AppBanner":"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUg.....VORK5CYII="}
But with help of above code, I can't convert this data into Image.
So how can I convert this data into image ?
Any Solution ?
Thanks in advance.

Use NSData-Base64 to convert base64 into NSData and then into UIImage
NSString *strBase64 = [yourResposeDict objectForKey:#"AppBanner"];
//decode strBase64 using NSData-Base64 library

Related

OSX App Unrecognized Selector error when downloaded image from a when downloaded image from a JSON web service

In my Mac app I am getting Data from hey JSON web service and one of the fields is an image. When I do a NSLog(#"%#", [dict valueForKeyPath:#"profileImageDataString"] ); I see all of the data and it is correct. And I can also put it in a NSURL object like this NSURL *imgUrl = [dict valueForKeyPath:#"profileImageDataString"]; and it is still correct. But when I try this NSData *imgData = [NSData dataWithContentsOfURL:imgUrl]; or this NSImage *userImage = [[NSImage alloc] initWithContentsOfURL:imgUrl];I get the error unrecognized selector sent to instance. If I put the data in a NSString, two thirds is cut off at the end.
I am trying to save the Image data from the Jason web service into a text file to that later it can be loaded into a NSImage on in a user settings view.
Someone tell me what it is that I'm doing wrong?
This is the value of profileImageDataString that is returned by the web service;
iVBORw0KGgoAAAANSUhEUgAAATQAAAE0CAYAAACigc+fAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAACC6SURBVHhe7Z37t1VV+cb7W/SIgCYgl8FNDOIWEAevEJY3aKSgiYNogGCCCYRiIFIMLiomKKAChZ7KAjMC5ZKEIYQgcbPM5KqAtzHmt2f6XccNvOw9995zrTXfuZ4fPuM5A845a+35zvc9z1rz9rV//etfJkT+/e9/U5Ur0c/777+vSm1BwxfUbJTEg2uSUbPTYBwabogahx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1GjUOJfkqdWaJeHBqJB3QMqm4tMnRoDqChqHEo0Y/kzBKty6GReECHoOpWQodWFjQQVbeSeCjnzBKtyaER/aADUONQ8hV0aAJoGKpuJfHg4swSrcqhEf0g8NQ4lJwPHVoJaBCqbiX6cXFisn5g/g91hyU8vt0T+gAAAABJRU5ErkJggg==
The string seems to be a base64 encoded string representation of an image.
Try to create an NSData object from the string and the image from the data.
NSString *imgDataString = [dict objectForKey:#"profileImageDataString"];
NSData *imgData = [[NSData alloc] initWithBase64EncodedString:imgDataString options:0];
NSImage *userImage = [[NSImage alloc] initWithData:imgData];
And I can also put it in a NSURL object like this NSURL *imgUrl = [dict valueForKeyPath:#"profileImageDataString"]; and it is still correct.
You haven't got an NSURL object. You've got an NSString object. Declaring that your pointer refers to an NSURL and using the untyped getter valueForKeyPath: (or, even, much more correctly, objectForKey:) does not change the type of the object.
To convert a string to a URL use +[NSURL URLWithString:]. But what you're showing us isn't a URL. So why try to make it one at all?
But when I try this NSData *imgData = [NSData dataWithContentsOfURL:imgUrl]; or this NSImage *userImage = [[NSImage alloc] initWithContentsOfURL:imgUrl];I get the error unrecognized selector sent to instance.
That's because you're supplying an NSString, which does not implement the same selectors as an NSURL.
If I put the data in a NSString, two thirds is cut off at the end.
No it isn't; however when you log any object, all you get is enough information to help in debugging. Using NSLog is not intended to be a way to store the same amount of data in another form, or indeed to do anything strictly well defined other than help you to debug.
Get your string, use the approach as suggested by vadian.

Receiving an image as blob from server converting back to image with Objective-C fails

My service returns the following which is a blob representing an image:
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADhASwDASIAAhEBAxEB/8QAHwAAAQUBA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CkRhSOtKADUhwaaVx0/SkBJaKrXSbuR1rZChmwXbaO1YQ+U7gcMO9W4ryZWBJ49qadhNF50GcHOCeTUKkBDl+nQUn2oPnaWBPXdTNwZfmYHPTA5qriJAwVgNwOeeTzTC7tk9P8aCu3JDZP8AKopSc8Dt2aquIcz5HX/vqowCcAdcdu9MDZzgE89M0xhl+OPWncQ/KjAwPfkk1EZB5uCmEU9cfyppOzOQMHgU1pMkEE8dDnP4UxEhkbnJwW/yKZuKbixU5qOSYs4B4OP8/jTDJ8gByOv+TQBIzRhd2Qf97qKhaZVfcjKB39aa8mRkbgepPtVdtrkEZyBQBZMoJBbkjqCcUiEtkjC89MVWVhgnk5z+FEbOy9W44+7SsB5tqP8AyE7v/rs//oRqOD/j4j/3hRRQxjbv/j9m/wCuh/nTD0oopgPp1FFIDd8O/fb/AHhXXx/dNFFUgJUq3af65aKKBmifvN/vGnx/6z8aKKBGi/8Aq/xpkv3BRRSYyCTov0rD1j/XR/7tFFSBBD2rSt+p+lFFQyiweg+lI3UUUVLGNP3R9KeP4aKKkYx/9W1Sr0oopiHDv9KfbffH4UUU0MmPQ1DJ0P40UVRDI0+6fxqvL/q/8+tFFWhD2+6/1H8qgg/1zf73+NFFMTIbv7x/3hTf4j9T/WiimIjj/wBX+H9KgT7jf7woooAaPvfgf51et/8AVn60UUCZ/9k=
In Oobjective-C I'm trying to convert it back to an image and I get exception, I even tried saving it to a file testing different extensions (png, jpg, jpeg, bmp) nothing worked the only way the file opens is with a txt extension.
How can I convert this blob into the image it should be?
That looks like Base64 encoded JPEG image data, so this should work:
NSString *b64String = #"/9j/4AAQSkZJRgABAQEASA ..."; // your string from the server
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:b64String options:0];
UIImage *image = [UIImage imageWithData:imageData];
initWithBase64EncodedString is available since iOS 7.0. If you want to target
earlier iOS versions, you can use the following method instead:
NSData *imageData = [[NSData alloc] initWithBase64Encoding:b64String];

UIImage does not showing

I am using following code to convert base64 string to uiimmage and also getting NSDAta but
i am unable to get image.please check following code.
base64String //contaning base64 string
NSData *imageData = [base64String dataUsingEncoding:NSUTF8StringEncoding];
UIImage *ret = [[UIImage alloc] initWithData:imageData];
Thanks in advance
UIImage does not directly recognize base64 encoded data. Check Base64 encoding options on the Mac and iPhone for information on base64 decoding in iOS. It has NSData+Base64 category for parsing base64 string into NSData.

Converting a UIImage to jpeg/png file for sharing using AddThis Plug-in

I want to convert a UIImage into a format such as a jpeg or png so that I can then share that file using the IOS plug-in called "AddThis".
I tried to share it using just the UIImage but the plug-in doesn't support it so I need to find a way to convert the UIImage to a jpeg first, then add it into this code:
[AddThisSDK shareImage:[UIImage imageNamed:#"test.jpg] withService:#"twitter" title:#"I'm sharing something" description:#"Random description of image"];
the code has to have shareImage:[UIImageNamed:#""] otherwise an error occurs.
So far I've tried to convert it using UIImageJPEGRepresentation but I don't think I've done it properly. To be honest I tried to do it similarly to how you'd convert it straight from taking an image:
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:#"photo_boom.jpg"];
[UIImageJPEGRepresentation(shareImage, 1.0) writeToFile:jpgPath atomically:YES];
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:#"photo_boom.jpg"];
NSLog(#"Documents directory: %#", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
Something tells me this isn't the correct way... mainly because I haven't been able to get it to work.
I'd really appreciate any kind of help!
Basically, I've made a UIImage from converting a UIView:
UIGraphicsBeginImageContext(firstPage.bounds.size);
[firstPage.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
Which I then want to give a jpeg format because when I tried to simply put it in as
[AddThisSDK shareImage:image withService:#"twitter" title:#"I'm sharing something" description:#"Random description of image"];
It gives me an error
UIImage has its own internal representation of an image, so it's irrelevant whether you load it with jpeg or png data.
The API call you're interested has a UIImage as the first parameter, so something along the lines of
[AddThisSDK shareImage:[UIImage imageNamed:#"photo_boom.jpg"]
withService:#"twitter"
title:#"I'm sharing something"
description:#"Random description of image"];
should work, provided photo_boom.jpg is included in your bundle. If you're loading a previously saved image from a folder, you'll need something like this:
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:#"photo_boom.jpg"];
UIImage * myImage = [UIImage imageWithContentsOfFile: jpgPath];
[AddThisSDK shareImage:myImage
withService:#"twitter"
title:#"I'm sharing something"
description:#"Random description of image"];
If that doesn't work, have you tried putting a breakpoint on the AddThisSDK line, and checking the value of image? Type po image on the console.

How to convert the binary to pdf file on iPhone?

I receive a binary pdf file, which is base64Binary encoded.
How can I convert it back on the iPhone? What tool kits can I use?
Thanks.
Solved:
NSData theData = [NSData dataWithData:[GTMBase64 decodeString:theBinary]]; //first transfer it to NSData.
[m_oTestingWeb loadData:theData
MIMEType:#"application/pdf"
textEncodingName:#"UTF-8"
baseURL:nil]; //using the web view to show it back
Solution
NSString *binaryString = [myDict objectForKey:#"key"];
NSData* myData = [NSData dataFromBase64String: binaryString];
NSLog(#" %#",datas);
[self savePDF:myData];
and save PDF is like this
- (void)savePDF:(NSData *)pdfContent
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask ,YES );
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *finalPath = [documentsDirectory stringByAppendingPathComponent:#"myPdf.pdf"];
NSLog(#"%#",finalPath);
NSURL *url = [NSURL fileURLWithPath:finalPath];
[pdfContent writeToURL:url atomically:YES];
// [aWebView loadRequest:[NSURLRequest requestWithURL:url]];
}
Get headers here.
If you mean NSData by the word "binary" then you can follow the following method.
I think if the binary data is already in PDF format then we can just use the normal NSData method to writeToFile:atomically to write it to the file.
[<NSDataObject> writeToFile:<FilePath> atomically:YES];
And then you can use the DocInteraction to open and display a PDF File.
Hope this helps you.
To convert a binary (base64 pdf string) to pdf and show it you can do this for Swift 3:
// Here you convert the binary base 64 pdf string to pdf
let pdfData = Data(base64Encoded: theBase64PDFString, options: .ignoreUnknownCharacters)
// here you can display the pdf on a UIWebView
webView.load(pdfData!,
mimeType: "application/pdf",
textEncodingName: "UTF-8",
baseURL: URL(fileURLWithPath: ""))
To display a PDF, you can simply use a UIWebView and feed it the PDF. If you want it a little more sophisticated, look at Apple's ZoomingPDFViewer sample code (found that one in an answer to another question).
Visit this site base64 encoding. Here You will get code for decoding base64 data to NSData. Using that data you can save pdf, view pdf using UIWebView or using Quartz Core.
To convert the binary into a PDF file
#IBOutlet var pdfView: PDFView!
guard
var fileURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).last,
let convertedData = Data(base64Encoded: data.base64EncodedData()) // data is the binary pdf
else {
// handle error when getting documents URL
return
}
fileURL.appendPathComponent("filename.pdf")
do {
try convertedData.write(to: documentsURL)
} catch {
// handle write error
}
Bonus: View the PDF without deprecated UIWebView API
let pdfView = PDFView(frame: self.view.bounds)
self.view.addSubview(pdfView)
// Fit content in PDFView.
pdfView.autoScales = true
pdfView.document = PDFDocument(url: fileURL)
Maybe it's a bit late, but I hope it will help someone else at least.