Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ALAsset Image Size

Given an ALAsset that represents a photo, is it possible to retrieve the size of the photo (height and width) without loading the image into a UIImageView and also without using the aspectRationThumnail method?

like image 775
Ser Pounce Avatar asked Nov 28 '22 09:11

Ser Pounce


2 Answers

Just a note: iOS 5.1 introduces a new property dimensions for an ALAssetRepresentation instance. This returns a CGSize structure with the dimensions of the original image and might be the best solution for this problem in the future.

Cheers,

Hendrik

like image 183
holtmann Avatar answered Dec 09 '22 02:12

holtmann


float width = asset.defaultRepresentation.dimensions.width;
float height = asset.defaultRepresentation.dimensions.height;

it fast, stable, and gives the actual dimensions. I've used it with ALAsset of videos.

like image 20
a.burchak Avatar answered Dec 09 '22 02:12

a.burchak