UIImage
category to work with WebP
image files in iOS.
Drag and drop the Classes
folder and WebP.framework
into your project.
Getting started with WebP-UIImage
is simple.
Import framework #import "UIImage+WebP.h"
and call following methods:
- (NSData *)dataWebPWithQuality:(float)quality;//quality = 0..100
+ (UIImage*)imageWithWebPAtPath:(NSString *)filePath;
+ (UIImage *)imageWithWebPData:(NSData *)imgData;
@property (nonatomic, readonly) NSData *dataWebPLossless;
- (BOOL)writeWebPToDocumentsWithFileName:(NSString *)filename quality:(float)quality;
- (BOOL)writeWebPLosslessToDocumentsWithFileName:(NSString *)filename;
I made also an NSValueTransformer
subclass called ImageToWebPDataTransformer
.
You can use it in CoreData to store images with less sizes than jpeg.
I use 75 quality value as it is default Google value.
The project is heavily based on nyteshade/iOSWebPWithAlphaExample
MIT
No speed/size tests were done. You can make your own and commit it here.