美文网首页
获取图片的详细信息

获取图片的详细信息

作者: 学学学q | 来源:发表于2018-02-07 14:22 被阅读13次
  NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];

  -(void)getImageDetailInfo:(NSURL*)imageUrl imageData:(NSData *)data {
          __block NSString* imageFileName;

          ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
          [assetslibrary assetForURL:imageUrl
               resultBlock:^(ALAsset *myasset){
                   ALAssetRepresentation *representation = [myasset defaultRepresentation];
                   imageFileName = [representation UTI];
                   
                   NSString *suffix = [[[representation UTI] componentsSeparatedByString:@"."] lastObject];
                   
                   NSString *guid = [self stringWithUUID];
                   NSString *filePath = [RGetFilePath getSavePathWithFileSuffix:suffix fileName:guid];
                   
                   NSFileManager *fileManager = [[NSFileManager alloc] init];
                   BOOL success = [fileManager fileExistsAtPath:filePath];
                   if (success) {
                       [fileManager removeItemAtPath:filePath error:nil];
                   }
                   
                   [data writeToFile:filePath atomically:YES]; //写入本地
                   success = [fileManager fileExistsAtPath:filePath];
                   
                   if (success) {
                  }
}

相关文章

网友评论

      本文标题:获取图片的详细信息

      本文链接:https://www.haomeiwen.com/subject/gjmozxtx.html