Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattt/WebPImageSerialization
Complete WebP Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling
https://github.com/mattt/WebPImageSerialization
Last synced: 7 days ago
JSON representation
Complete WebP Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling
- Host: GitHub
- URL: https://github.com/mattt/WebPImageSerialization
- Owner: mattt
- License: mit
- Archived: true
- Created: 2014-02-27T00:32:46.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2021-04-06T17:44:16.000Z (over 3 years ago)
- Last Synced: 2024-10-07T12:04:31.365Z (about 1 month ago)
- Language: C
- Size: 5.93 MB
- Stars: 281
- Watchers: 6
- Forks: 25
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebPImageSerialization
`WebPImageSerialization` encodes and decodes between `UIImage`
and [WebP](https://developers.google.com/speed/webp/) images,
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 `WEBP_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 == 'WebPImageSerialization' then
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||=
['$(inherited)', 'WEBP_NO_UIIMAGE_INITIALIZER_SWIZZLING=1']
end
end
end
end
```## Usage
### Decoding
```objective-c
UIImageView *imageView = ...;
imageView.image = [UIImage imageNamed:@"image.webp"];
```### Encoding
```objective-c
NSData *data = UIImageWebPRepresentation(imageView.image);
```---
## Contact
Mattt ([@mattt](https://twitter.com/mattt))
## License
WebPImageSerialization is available under the MIT license. See the LICENSE file for more info.