おじさんエンジニアの日記

おじさんエンジニアがWeb関連の技術、ガンプラのことを書くブログ

UIImageで画像のサイズを取得

UIImageで画像のサイズを取得するには以下の方法で取得できる

UIImage *image= [UIImage imageNamed:@"ファイル名"];

CGImageRef ref = image.CGImage;
int width = CGImageGetWidth(ref);
int height = CGImageGetHeight(ref);

NSLog(@"画像サイズ:%d x %d", width, height);

もしくは、

UIImage *image= [UIImage imageNamed:@"ファイル名"];

int width = img.size.width;
int height = img.size.height;
NSLog(@"画像サイズ:%d x %d", width, height);