0

So Im trying to upload images from photo library to a server with alamofire post method, the uploading parts is working. However it's when I convert the UIImage to Base64 before uploading that stripes/removes all the exif information from the image.

Before converting the UIImage to Base64 all exif information is there and accessible but after the conversion the exif information is removed. I have tried uploading a Base64 of the same UIImage but converted on a website and that kept the exif information, that proves that the problem is with the swift version of the conversion.

Here is what the converting part of the code looks like:

func imageTobase64(image: UIImage) -> String {
        var base64String = ""
        let  cim = CIImage(image: image)
        if (cim != nil) {
            let imageData = image.jpegData(compressionQuality: 1.0)
            base64String = imageData!.base64EncodedString(options: NSData.Base64EncodingOptions.lineLength64Characters)
        }
        return base64String
    }
Bhavesh Nayi
  • 705
  • 4
  • 15
  • Possible duplicate of [How to write exif metadata to an image (not the camera roll, just a UIImage or JPEG)](https://stackoverflow.com/questions/9006759/how-to-write-exif-metadata-to-an-image-not-the-camera-roll-just-a-uiimage-or-j) – mag_zbc May 02 '19 at 11:06
  • @mag_zbc Im looking for an answer in swift and the problem Im facing is different from the one in your comment. Thanks for the comment anyway. – SomeoneNice May 02 '19 at 11:53
  • Your question is answered there, in the first line of the accepted answer - _UIImage does not contain metadata information_ – mag_zbc May 02 '19 at 11:54

0 Answers0