Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone retrieve image using URL using ALAsset

I want to know how to how to retrieve a image using URL. I am using the ALAsset. I followed the answer (the one with the tick mark) from the following link display image from URL retrieved from ALAsset in iPhone. How to retrieve the image and upload it?

like image 613
rakendu Avatar asked Feb 15 '11 11:02

rakendu


2 Answers

Have you managed to get the ALAsset? Once you do, getting the image is easy. To get a thumbnail, the asset has a method...thumbnail.

UIImage *img = [UIImage imageWithCGImage:[myAsset thumbnail]];

To get the full Res image you have to go through the default representation.

UIImage *img = [UIImage imageWithCGImage:[[myAsset defaultRepresentation] fullResolutionImage]

Hope this helps

like image 140
Mike Avatar answered Oct 03 '22 09:10

Mike


I know this is an old question but just in case anyone else comes I found another method (requires iOS 5+) that returns an easier to work with image:

UIImage *img = [UIImage imageWithCGImage:[[myAsset defaultRepresentation] 
               fullScreenImage];


From the docs of fullScreenImage:

In iOS 5 and later, this method returns a fully cropped, rotated, and adjusted image—exactly as a user would see in Photos or in the image picker.

monkybonk05's answer does work, but it not cropped or rotated.

like image 31
user1369511 Avatar answered Oct 03 '22 09:10

user1369511