2

I am receiving from a webservice an animated gif url.

how can i save that gif image to photo album ?

What i did is downloading the data and converting it to UIImage using category helper

UIImage* gifImage = [UIImage animatedImageWithAnimatedGIFURL:[NSURL 
URLWithString:self.resultImageUrl]];

and after that saving it useing

writeImageToSavedPhotosAlbum

but the image is saved as first frame.

so i thought to try and save directly the NSData using

writeImageDataToSavedPhotosAlbum

But i can't find any documentation about what to put in the metadata of the image so the album will know it's gif file.

Bottom line, I want the gif file will be visible in the user photo album and when he will send it using email client it will send it as gif animation and not just first frame

Please advise, Thanks

Armali
  • 18,255
  • 14
  • 57
  • 171
ibm123
  • 1,214
  • 2
  • 15
  • 39

1 Answers1

6
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

NSData *data = [NSData dataWithContentsOfURL:[self getCurrentGIFURL]];

[library writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) {}

See this answer

Community
  • 1
  • 1
Bug
  • 2,576
  • 2
  • 21
  • 36