Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattt/AnimatedGIFImageSerialization
Complete Animated GIF Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling
https://github.com/mattt/AnimatedGIFImageSerialization
Last synced: 7 days ago
JSON representation
Complete Animated GIF Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling
- Host: GitHub
- URL: https://github.com/mattt/AnimatedGIFImageSerialization
- Owner: mattt
- License: mit
- Archived: true
- Created: 2014-03-25T18:06:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-07-06T14:55:26.000Z (over 5 years ago)
- Last Synced: 2024-10-29T12:33:23.571Z (about 1 month ago)
- Language: Objective-C
- Size: 534 KB
- Stars: 1,081
- Watchers: 27
- Forks: 104
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - AnimatedGIFImageSerialization - Complete Animated GIF Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling (Media / GIF)
- awesome-gif - AnimatedGIFImageSerialization - *decodes an UIImage from Animated GIFs image data* (Libraries / Objective-C)
- awesome-ios-star - AnimatedGIFImageSerialization - Complete Animated GIF Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling (Media / GIF)
README
# AnimatedGIFImageSerialization
> This library is no longer maintained.
> In iOS 13+ and macOS 10.15+, use [`CGAnimateImageAtURLWithBlock`](https://developer.apple.com/documentation/imageio/3333271-cganimateimageaturlwithblock) instead.`AnimatedGIFImageSerialization` decodes an `UIImage` from
[Animated GIFs](http://en.wikipedia.org/wiki/Graphics_Interchange_Format),
following the API conventions of Foundation's `NSJSONSerialization` class.By default, `UIImage` initializers can't decode animated images from GIF files.
This library uses swizzling to provide this functionality for you.
To opt out of this behavior,
set `ANIMATED_GIF_NO_UIIMAGE_INITIALIZER_SWIZZLING` in your build environment.
If you're using CocoaPods,
you can add this build setting to your `Podfile`:```ruby
post_install do |r|
r.pods_project.targets.each do |target|
if target.name == 'AnimatedGIFImageSerialization' then
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||=
['$(inherited)', 'ANIMATED_GIF_NO_UIIMAGE_INITIALIZER_SWIZZLING=1']
end
end
end
end
```## Usage
### Decoding
```objective-c
UIImageView *imageView = ...;
imageView.image = [UIImage imageNamed:@"animated.gif"];
```![Animated GIF](https://raw.githubusercontent.com/mattt/AnimatedGIFImageSerialization/master/Example/Animated%20GIF%20Example/animated.gif)
### Encoding
```objective-c
UIImage *image = ...;
NSData *data = [AnimatedGIFImageSerialization animatedGIFDataWithImage:image
duration:1.0
loopCount:1
error:nil];
```---
## Contact
Mattt ([@mattt](https://twitter.com/mattt))
## License
AnimatedGIFImageSerialization is available under the MIT license.
See the LICENSE file for more info.