Retrieving UIImage in byte form from NSArray - iOS - objective-c

I have an array which contains a set of UIImage in byte forms. --My partner saved the UIImage in the database, and he created an array to retrieve the data-- I created this to retrieve the data from the array:
for (NSDictionary *row in arr){
NSData *imgData = [row objectForKey:#"ImageFile"];
When I put it in the NSLog, it gave the right data. However when I try to display the image using this:
UIImage *imgDis = [UIImage imageWithData:imgData];
It is giving me an error saying [__NSCFString bytes]: unrecognized selector sent to instance..
I honestly don't know what to do, so if anyone can help me it will be greatly appreciated.

As what #Safecase said in the comments, I decided to save the image path instead of the image itself. This way, I could just use UIImage imageWithContentsOfFile:imageFilePath to display the image. Thanks for the help!

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+vSm1BwxfUbJTEg2uSUbPTYBwabogahxL9uBSPEJUOLSMl8eCaXNTsNXeHhhuh6lYSDy5FI2SlQ0tZiX5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oOpWQodWFjQQVbeSeCjnzBKtyaER/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.

Load an image file to core data

I'm a new developer with objective c.
I have images stored in a folder on my computer and I want to insert it to my coredata, can someone please tell me how can I do so, cause I can't find the right way for this.
By the way its my first question so get mad on me :)
Thank you
You need an Entity:(b.e.: Photos), this entity need an attribute, with type is Binary Data. (b.e imageData.
Here the example to save and to show:
// Save the image.
UIImage *imageToSave;
NSManagedObject *newPhoto = [NSEntityDescription entityForName:#"Photo" inManagedObjectContext:yourManagedObjectContext];
NSData *imageData = UIImageJPEGRepresentation(imageEdited, 0.7);
[newPhoto setValue:imageData forKey:#"imageData"];
[yourManagedObjectContext save:&error];
// Sow the image
UIImage *image = [UIImage imageWithData:[newPhoto valueForKey:#"imageData"]];

unable to save an NSMutableArray of image using persistent storage

I am trying to store an NSMutableArray of images using persistive storage but it is not storing it
here is my code
[imagingList addObject:image ]; //image is of type UIImage
imagingHistory=[NSUserDefaults standardUserDefaults];
[imagingHistory setObject:imagingList forKey:#"imaging history" ];
and in my view did load I write
imagingList = [[NSUserDefaults standardUserDefaults] mutableArrayValueForKey:#"imaging history" ];
when I re-load the application the list of objects is set back to Zero
am I missing something ?
You can't save a UIImage directly in the user defaults. You have to convert it to an NSData first. Just by chance, when I was looking for the NSUserDefaults reference page to answer this question, a found a tutorial on how to do exactly what you want.
Hmm you really shouldn't be trying to save UIImages into NSUserDefaults. Take a look at this resource https://discussions.apple.com/thread/1729849?start=0&tstart=0 it explains how to get the NSData of the image and write it to a file. From there you can save a reference (NSURL or NSString) to the image's path in your app's document directory and you can load it from there using something like UIImage aImage = [UIImage imageWithData:[NSData datWithContentsOfURL:pathURL]].
Hope that helps.

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.

Error saving NSImage as NSData

I am using the following code to save a frame of a movie to my desktop:
NSCIImageRep *imageRep = [NSCIImageRep imageRepWithCIImage:[CIImage imageWithCVImageBuffer:imageBuffer]];
NSImage *image = [[[NSImage alloc] initWithSize:[imageRep size]] autorelease];
[image addRepresentation:imageRep];
CVBufferRelease(imageBuffer);
NSArray *representations = [image representations];
NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations usingType:NSJPEGFileType properties:nil];
[bitmapData writeToFile:#"/Users/ricky/Desktop/MyImage.jpeg" atomically:YES];
At the second last line of code, I receive the following messages in the console, with no result being saved to the desktop:
<Error>: CGImageDestinationFinalize image destination does not have enough images
CGImageDestinationFinalize failed for output type 'public.jpeg'
The NSImage is still an allocated object for the entire method call, so I'm not sure why I am receiving complaints about insufficient amount of images.
I'd appreciate any help.
Thanks in advance,
Ricky.
I think the source of the problem is that you're passing an array of NSCIImageRep objects to representationOfImageRepsInArray:usingType:properties:, which I believe expects an array of NSBitmapImageRep objects.
What you want to do is create an NSBitmapImageRep from your CIImage. Then you can use that to write to disk. That would be roughly:
CIImage *myImage = [CIImage imageWithCVImageBuffer:imageBuffer];
NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCIImage:myImage];
NSData *jpegData [bitmapRep representationUsingType:NSJPEGFileType properties:nil];
[jpegData writeToFile:#"/Users/ricky/Desktop/MyImage.jpeg" atomically:YES];
Of course, you'd want to handle any error cases and probably pass a properties dictionary to fine-tune the JPEG creation.
I'm sorry i don't really know why your code doesn't work, but approaching it a different way (and i think more efficiently than your CVImageBuffer to CIImage to NSCIImageRep to NSImage to NSData, albeit at a slightly lower level):-
CVImageBuffer to CGImage
CGImage to jpg file
I don't have code ready made to do this but extracting the right stuff from those examples should be straight forward.