美文网首页
iOS 查看照片详情 照片信息

iOS 查看照片详情 照片信息

作者: 唐人街的乞丐 | 来源:发表于2020-10-13 11:43 被阅读0次

    TZImagePickerController 选择照片,在回调方法中查看照片信息,照片详情,查看参数。
    TZImagePickerController的代理TZImagePickerControllerDelegate方法
    -(void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos
    可以回调到想要的各种参数。

       -(void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos{
        UIImage * photo = photos.lastObject;
        self.imageView.image =photo;
        NSLog(@"photos = %@ \n assets = %@ \n infos = %@",photos,assets,infos);
        PHAsset * asset = assets[0];
        // 经纬度
        NSLog(@"latitude = %lf   longitude = %lf   ", asset.location.coordinate.latitude,asset.location.coordinate.longitude);
        
        // 海拔
        NSLog(@"altitude = %lf ", asset.location.altitude);
        
        // 类型:照片,视频,
        NSLog(@"mediaType = %ld", asset.mediaType);
        
        //  HRD,LIVE,
        NSLog(@"mediaSubtypes = %ld", asset.mediaSubtypes);
        
        //  创建时间
        NSLog(@"creationDate = %@", asset.creationDate);
        
        //  时间
        NSLog(@"duration = %f", asset.duration);
        
        //像素尺寸
        CGFloat width = photo.size.width;
        CGFloat height = photo.size.height;
        NSLog(@"像素尺寸 imagewidth = %f  imageheight =  %f",width,height);
        
    
        
        //  图片名称
        NSString *fileName = [asset valueForKey:@"filename"];
        NSLog(@"图片名字:%@",fileName);
        
        // 照片大小
        TZAssetModel * model = [[TZAssetModel alloc]init];
        model.asset = asset;
        [[TZImageManager manager] getPhotosBytesWithArray:@[model] completion:^(NSString *totalBytes) {
            NSLog(@"totalBytes =  %@",totalBytes);
        }];
    }
    

    PHImageManager 获取图片信息回调会调两次

      // 获取图片名字
            PHImageManager * imageManager = [PHImageManager defaultManager];
            [imageManager requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
               
    //            当前回调会调用两个次,第一次返回你指定尺寸的图片,第二次将会返回原尺寸图片
                if ([[info valueForKey:@"PHImageResultIsDegradedKey"]integerValue]==0){
                    //原尺寸图片
                } else {
                    //指定尺寸的图片
                }
            }];
    

    相关文章

      网友评论

          本文标题:iOS 查看照片详情 照片信息

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