2

I have been trying to convert an image to a .gif file contained in an NSData instance, but iOS provides only 2 methods for image format output:

  • UIImagePNGRepresentation
  • UIImageJPEGRepresentation

returning PNG files and JPEG files respectively as NSData. Is there any API or way to get NSData for .gif files?

I do not have a path or a URL for a file. It is a UIImage which I get after a call to my app's core. Soo, the below code will not work for my scenario.

NSString *pathForGif = [[NSBundle mainBundle] pathForResource: @"gifFile" ofType: @"gif"];
NSData *gifData = [NSData dataWithContentsOfFile: pathForGif];
NSLog(@"Data: %@", gifData);

Is there any way to output a .gif file from a UIImage?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
XYZ
  • 597
  • 1
  • 7
  • 19

0 Answers0