对于png图像,IOS无法获得exif数据。

时间:2021-08-27 08:57:22

I need to extract the Description part from the png image which is stored as meta data.

我需要从存储为元数据的png图像中提取描述部分。

When I run the command exiftool outimage.png from linux I am getting the details like

当我运行命令exftool outimage时。来自linux的png,我得到了一些细节

ExifTool Version Number         : 10.10
File Name                       : outimage.png
Directory                       : .
File Size                       : 387 kB
File Modification Date/Time     : 2017:10:30 12:18:23+05:30
File Access Date/Time           : 2017:10:30 12:18:26+05:30
File Inode Change Date/Time     : 2017:10:30 12:18:23+05:30
File Permissions                : rw-rw-r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 1080
Image Height                    : 1080
Bit Depth                       : 8
Color Type                      : RGB with Alpha
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Pixels Per Unit X               : 11811
Pixels Per Unit Y               : 11811
Pixel Units                     : meters
Description                     : Hi
Image Size                      : 1080x1080
Megapixels                      : 1.2

And the Description filed where my custom data will store, now I need to retrieve this data from ios objective see code. So I downloaded the same image to iPhone and using the below code I am not getting all the meta data

我的自定义数据将存储的描述文件,现在我需要从ios objective中检索这些数据。所以我下载了相同的图像给iPhone使用下面的代码,我没有得到所有的元数据

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

    //get eix data
     UIImage *orignalImage = [info valueForKey:UIImagePickerControllerOriginalImage];
     NSData *pngDataOriginal = UIImagePNGRepresentation(orignalImage);
     CGImageSourceRef source = CGImageSourceCreateWithData( (CFDataRef) pngDataOriginal, NULL);
    NSDictionary* metadata = (NSDictionary *)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source,0,NULL));
    NSLog(@" exifData %@", metadata);
}

Which print

它打印

exifData {
    ColorModel = RGB;
    Depth = 8;
    HasAlpha = 1;
    PixelHeight = 1080;
    PixelWidth = 1080;
    "{PNG}" =     {
        Chromaticities =         (
            "0.3127",
            "0.329",
            "0.64",
            "0.33",
            "0.3",
            "0.6",
            "0.15",
            "0.06"
        );
        Gamma = "0.45455";
        InterlaceType = 0;
        sRGBIntent = 0;
    };
}

And it doesn't include the Description filed.

它不包括描述文件。

I can resolve this issue>

我可以解决这个问题

1 个解决方案

#1


0  

I have resolved the problem using following code

我已经使用以下代码解决了这个问题

NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];

    if(referenceURL) {
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library assetForURL:referenceURL resultBlock:^(ALAsset *asset) {
            ALAssetRepresentation *rep = [asset defaultRepresentation];
            NSDictionary *metadata = rep.metadata;
            NSLog(@"image data %@", metadata);


        } failureBlock:^(NSError *error) {
            // error handling
        }];
    }

#1


0  

I have resolved the problem using following code

我已经使用以下代码解决了这个问题

NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];

    if(referenceURL) {
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library assetForURL:referenceURL resultBlock:^(ALAsset *asset) {
            ALAssetRepresentation *rep = [asset defaultRepresentation];
            NSDictionary *metadata = rep.metadata;
            NSLog(@"image data %@", metadata);


        } failureBlock:^(NSError *error) {
            // error handling
        }];
    }