- (IBAction)touchedImageInfo:(id)sender {
NSData *imagedata = [NSData dataWithContentsOfFile:_fileUrl];
CGImageSourceRef source = CGImageSourceCreateWithData((CFMutableDataRef)imagedata, NULL);
CFDictionaryRef dictRef = CGImageSourceCopyPropertiesAtIndex(source,0,NULL);
NSDictionary* metadata = (__bridge NSDictionary *)dictRef;
//NSLog(@"%@", metadata);
CGFloat width = [metadata[@"PixelWidth"] floatValue];
CGFloat height = [metadata[@"PixelHeight"] floatValue];
NSMutableString *message = [[NSMutableString alloc] init];
[message appendFormat:@"\n종류 : %@\n", [_fileUrl pathExtension]];
[message appendFormat:@"크기 : %.01f KB\n", (float)imagedata.length/1024.f];
[message appendFormat:@"해상도 : %d x %d\n", (int)width, (int)height];
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:@"파일 정보"
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"확인"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:yesButton];
[[Util topViewController] presentViewController:alert animated:YES completion:^{
CFRelease(source);
CFRelease(dictRef);
}];
}
댓글 없음:
댓글 쓰기