EXIF data read and write

前端 未结 2 741
囚心锁ツ
囚心锁ツ 2020-12-08 16:58

I searched for getting the EXIF data from picture files and write them back for Swift. But I only could find predefied libs for different languages.

I also found ref

2条回答
  •  离开以前
    2020-12-08 17:39

    I'm using this to get EXIF infos from an image file:

    import ImageIO
    
    let fileURL = theURLToTheImageFile
    if let imageSource = CGImageSourceCreateWithURL(fileURL as CFURL, nil) {
        let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil)
        if let dict = imageProperties as? [String: Any] {
            print(dict)
        }
    }
    

    It gives you a dictionary containing various informations like the color profile - the EXIF info specifically is in dict["{Exif}"].

提交回复
热议问题