Monday, 29 July 2019

Get (Read) Exif data from UIImage

I already do a lot of search for that but I didn't get any proper solution.

extension UIImage {

func getExifData() -> CFDictionary? {
    var exifData: CFDictionary? = nil

    if let data = self.jpegData(compressionQuality: 1.0) {
    //if let data = self.pngData() {
        data.withUnsafeBytes {(bytes: UnsafePointer<UInt8>)->Void in
            if let cfData = CFDataCreate(kCFAllocatorDefault, bytes, data.count) {
                let source = CGImageSourceCreateWithData(cfData, nil)
                exifData = CGImageSourceCopyPropertiesAtIndex(source!, 0, nil)
            }
        }
    }
    return exifData
}
}

i try with this code but i found this result.

{
    ColorModel = RGB;
    Depth = 8;
    Orientation = 1;
    PixelHeight = 1500;
    PixelWidth = 1124;
    ProfileName = "Display P3";
    "{Exif}" =     {
        PixelXDimension = 1124;
        PixelYDimension = 1500;
    };
    "{JFIF}" =     {
        DensityUnit = 0;
        JFIFVersion =         (
            1,
            0,
            1
        );
        XDensity = 72;
        YDensity = 72;
    };
    "{TIFF}" =     {
        Orientation = 1;
    };
}

but I missing lots of information.help me.

Thank In Advance



from Get (Read) Exif data from UIImage

No comments:

Post a Comment