I'm implementing an iOS app that uploads images to a web server. The app provides an extension that allows upload from apps like Twitter, Messages, etc.
When the image is selected by the user, it may be presented by the itemProvider
either as an UIImage
, Data
, or URL
. To deal with that, I create an UIImage
object from what the itemProvider
provides and send this new UIImage
object to the upload function.
This latter (the upload function) uses Alamofire to upload the image and thus, requires to have a Data
object, which I obtain by using UIImageJPEGRepresentation
or UIImagePNGRepresentation
of the UIImage
object. That works for most images but in the case of gif
, it does not. The .gif loses its animation property and only a static image is uploaded.
So my question is how to have a Data
object from the UIImage
object which preserves the .gif properties (animation) of the original file?
Thank you very much for the help you can provide.