Iphone UIImagePickerController原始图像与原始资产数据

Iphone UIImagePickerController原始图像与原始资产数据,iphone,xcode,ios5,alassetslibrary,uiimagepngrepresentation,Iphone,Xcode,Ios5,Alassetslibrary,Uiimagepngrepresentation,在我正在开发的应用程序中,我使用的是用户从相册中选择的图像。我需要上传照片的高分辨率版本到我的服务器 我正在使用imagePickerController,我确定我有两个选项 使用UIImagePickerControllerOriginalImage中的UIImage 使用UIImagePickerControllerReferenceURL和获取原始资源 AlassetLibrary assetForURL(我不喜欢这个,因为它会提示 用户使用其当前位置,我不需要) 我的问题是如果使用第

在我正在开发的应用程序中,我使用的是用户从相册中选择的图像。我需要上传照片的高分辨率版本到我的服务器

我正在使用imagePickerController,我确定我有两个选项

  • 使用UIImagePickerControllerOriginalImage中的UIImage
  • 使用UIImagePickerControllerReferenceURL和获取原始资源 AlassetLibrary assetForURL(我不喜欢这个,因为它会提示 用户使用其当前位置,我不需要)
我的问题是如果使用第一个选项与第二个选项,图像质量是否有任何差异?

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

    //option 1
            UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
            NSData *imgData = UIImagePNGRepresentation(image);

    // option 2 (will prompt user to allow use of current location)
            NSURL *imgURL = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
            __block NSData* imgData;

            ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];

            [assetLibrary assetForURL:img resultBlock:^(ALAsset *asset)
             {
                 ALAssetRepresentation *rep = [asset defaultRepresentation];
                 Byte *buffer = (Byte*)malloc(rep.size);
                 NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
                 imgData = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES]; 
             }
                       failureBlock:^(NSError *err) {
                             NSLog(@"Error: %@",[err localizedDescription]);
                         }]; 
        }

我使用这两个选项对图像进行了比较测试。使用选项1,图像的大小是原来的两倍(4.22MB对2.04MB)。在Photoshop中查看照片,质量似乎没有任何重大差异。在查看标高时,由选项1创建的标高不太平滑(下图)。查看文件属性时,由选项1创建的文件缺少一些由选项2创建的文件所具有的“原点”、“相机”和“高级照片”选项。我还没有决定我将使用哪种方式,但希望这些信息能帮助其他人


我使用的是选项2,没有位置许可,它可以获得一张图像。(我仍然无法使用AlassetLibrary访问整个库。)这在iOS 5和iOS 6上运行。