Merge pull request #3048 from dreampiggy/feature_webp_ios14

Supports built-in WebP/AWebP codec from ImageIO for iOS 14/tvOS 14/macOS 11/watchOS 7
This commit is contained in:
DreamPiggy 2020-07-15 17:58:11 +08:00 committed by GitHub
commit e7b87885ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 304 additions and 174 deletions

View File

@ -57,17 +57,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A629ED1D0E07600089D7DD"
BuildableName = "SDWebImage Watch Demo.app"
BlueprintName = "SDWebImage Watch Demo"
ReferencedContainer = "container:SDWebImage Demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -82,7 +71,7 @@
notificationPayloadFile = "SDWebImage Watch Demo Extension/PushNotificationPayload.apns">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/SDWebImage iOS Demo">
<BuildableReference
BuildableIdentifier = "primary"
@ -92,17 +81,6 @@
ReferencedContainer = "container:SDWebImage Demo.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A629ED1D0E07600089D7DD"
BuildableName = "SDWebImage Watch Demo.app"
BlueprintName = "SDWebImage Watch Demo"
ReferencedContainer = "container:SDWebImage Demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@ -112,7 +90,7 @@
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/SDWebImage iOS Demo">
<BuildableReference
BuildableIdentifier = "primary"

View File

@ -10,6 +10,7 @@
#import "MasterViewController.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@implementation AppDelegate
@ -24,6 +25,18 @@
NSString *fileName = [[SDImageCache sharedImageCache] cachePathForKey:key].lastPathComponent;
return [bundledPath stringByAppendingPathComponent:fileName.stringByDeletingPathExtension];
};
if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) {
// iOS 14 supports WebP built-in
[[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]];
} else {
// iOS 13 does not supports WebP, use third-party codec
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
}
if (@available(iOS 13, tvOS 13, macOS 10.15, watchOS 6, *)) {
// For HEIC animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now.
[[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
// Override point for customization after application launch.

View File

@ -9,7 +9,6 @@
#import "MasterViewController.h"
#import "DetailViewController.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@interface MyCustomTableViewCell : UITableViewCell
@ -52,9 +51,6 @@
target:self
action:@selector(flushCache)];
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; // For WebP static/animated image
[[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]]; // For HEIC static/animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now.
// HTTP NTLM auth example
// Add your NTLM image url to the array below and replace the credentials
[SDWebImageDownloader sharedDownloader].config.username = @"httpwatch";

View File

@ -8,6 +8,9 @@
#import "AppDelegate.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@interface AppDelegate ()
@end
@ -16,6 +19,17 @@
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) {
// iOS 14 supports WebP built-in
[[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]];
} else {
// iOS 13 does not supports WebP, use third-party codec
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
}
if (@available(iOS 13, tvOS 13, macOS 10.15, watchOS 6, *)) {
// For HEIC animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now.
[[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]];
}
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {

View File

@ -8,7 +8,6 @@
#import "ViewController.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@interface ViewController ()
@ -25,8 +24,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
// For animated GIF rendering, set `animates` to YES or will only show the first frame
self.imageView2.animates = YES; // `SDAnimatedImageRep` can be used for built-in `NSImageView` to support better GIF & APNG rendering as well. No need `SDAnimatedImageView`
self.imageView4.animates = YES;

View File

@ -8,6 +8,9 @@
#import "AppDelegate.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@interface AppDelegate ()
@end
@ -17,6 +20,18 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) {
// iOS 14 supports WebP built-in
[[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]];
} else {
// iOS 13 does not supports WebP, use third-party codec
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
}
if (@available(iOS 13, tvOS 13, macOS 10.15, watchOS 6, *)) {
// For HEIC animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now.
[[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]];
}
return YES;
}

View File

@ -8,7 +8,6 @@
#import "ViewController.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@interface ViewController ()
@ -25,7 +24,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
[self.imageView1 sd_setImageWithURL:[NSURL URLWithString:@"https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"]];
[self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"http://www.ioncannon.net/wp-content/uploads/2011/06/test2.webp"]];

View File

@ -8,10 +8,24 @@
#import "ExtensionDelegate.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@implementation ExtensionDelegate
- (void)applicationDidFinishLaunching {
// Perform any final initialization of your application.
if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) {
// iOS 14 supports WebP built-in
[[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]];
} else {
// iOS 13 does not supports WebP, use third-party codec
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
}
if (@available(iOS 13, tvOS 13, macOS 10.15, watchOS 6, *)) {
// For HEIC animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now.
[[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]];
}
}
- (void)applicationDidBecomeActive {

View File

@ -8,8 +8,6 @@
#import "InterfaceController.h"
#import <SDWebImage/SDWebImage.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@interface InterfaceController()
@ -27,7 +25,6 @@
[super awakeWithContext:context];
// Configure interface objects here.
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
}
- (void)willActivate {

View File

@ -103,6 +103,8 @@
325F7CCB238942AB00AEDFCC /* UIImage+ExtendedCacheData.m in Sources */ = {isa = PBXBuildFile; fileRef = 325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */; };
325F7CCC2389463D00AEDFCC /* UIImage+ExtendedCacheData.m in Sources */ = {isa = PBXBuildFile; fileRef = 325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */; };
325F7CCD2389467800AEDFCC /* UIImage+ExtendedCacheData.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 325F7CC8238942AB00AEDFCC /* UIImage+ExtendedCacheData.h */; };
3263626E24AEEEB0008FB119 /* SDImageAWebPCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
3263626F24AEEEB0008FB119 /* SDImageAWebPCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3263626D24AEEEB0008FB119 /* SDImageAWebPCoder.m */; };
326E2F2E236F0B23006F847F /* SDAnimatedImagePlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 326E2F2C236F0B23006F847F /* SDAnimatedImagePlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
326E2F2F236F0B23006F847F /* SDAnimatedImagePlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 326E2F2D236F0B23006F847F /* SDAnimatedImagePlayer.m */; };
326E2F30236F0B23006F847F /* SDAnimatedImagePlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 326E2F2D236F0B23006F847F /* SDAnimatedImagePlayer.m */; };
@ -113,10 +115,10 @@
327054D6206CD8B3006EA328 /* SDImageAPNGCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 327054D2206CD8B3006EA328 /* SDImageAPNGCoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
327054DA206CD8B3006EA328 /* SDImageAPNGCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 327054D3206CD8B3006EA328 /* SDImageAPNGCoder.m */; };
327054DC206CD8B3006EA328 /* SDImageAPNGCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 327054D3206CD8B3006EA328 /* SDImageAPNGCoder.m */; };
3287E6D1244C0C1400007311 /* MKAnnotationView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 3287E6CD244C0C1400007311 /* MKAnnotationView+WebCache.m */; };
3287E6D2244C0C1400007311 /* MKAnnotationView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 3287E6CE244C0C1400007311 /* MKAnnotationView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
327F2E83245AE1650075F846 /* SDWebImageOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 327F2E82245AE1650075F846 /* SDWebImageOperation.m */; };
327F2E84245AE1650075F846 /* SDWebImageOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 327F2E82245AE1650075F846 /* SDWebImageOperation.m */; };
3287E6D1244C0C1400007311 /* MKAnnotationView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 3287E6CD244C0C1400007311 /* MKAnnotationView+WebCache.m */; };
3287E6D2244C0C1400007311 /* MKAnnotationView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 3287E6CE244C0C1400007311 /* MKAnnotationView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
328BB69E2081FED200760D6C /* SDWebImageCacheKeyFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 328BB69A2081FED200760D6C /* SDWebImageCacheKeyFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
328BB6A22081FED200760D6C /* SDWebImageCacheKeyFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 328BB69B2081FED200760D6C /* SDWebImageCacheKeyFilter.m */; };
328BB6A42081FED200760D6C /* SDWebImageCacheKeyFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 328BB69B2081FED200760D6C /* SDWebImageCacheKeyFilter.m */; };
@ -187,7 +189,6 @@
3298655D2337230C0071958B /* SDImageHEICCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3298655B2337230C0071958B /* SDImageHEICCoder.m */; };
3298655E2337230C0071958B /* SDImageHEICCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3298655B2337230C0071958B /* SDImageHEICCoder.m */; };
3298655F233723220071958B /* SDImageHEICCoder.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3298655A2337230C0071958B /* SDImageHEICCoder.h */; };
32986562233737C70071958B /* SDImageHEICCoderInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 32986560233737C70071958B /* SDImageHEICCoderInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
329A185B1FFF5DFD008C9A2F /* UIImage+Metadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+Metadata.h */; settings = {ATTRIBUTES = (Public, ); }; };
329A185F1FFF5DFD008C9A2F /* UIImage+Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */; };
329A18611FFF5DFD008C9A2F /* UIImage+Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */; };
@ -221,6 +222,7 @@
32D3CDCE21DDE87300C4DB49 /* UIImage+MemoryCacheCost.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D3CDCC21DDE87300C4DB49 /* UIImage+MemoryCacheCost.m */; };
32D3CDCF21DDE87300C4DB49 /* UIImage+MemoryCacheCost.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D3CDCC21DDE87300C4DB49 /* UIImage+MemoryCacheCost.m */; };
32D3CDD121DDE87300C4DB49 /* UIImage+MemoryCacheCost.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D3CDCD21DDE87300C4DB49 /* UIImage+MemoryCacheCost.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D9EE4B24AF259B00EAFDF4 /* SDImageAWebPCoder.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */; };
32E5690822B1FFCA00CBABC6 /* SDWebImageOptionsProcessor.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 324406292296C5F400A36084 /* SDWebImageOptionsProcessor.h */; };
32E67311235765B500DB4987 /* SDDisplayLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 32E6730F235765B500DB4987 /* SDDisplayLink.h */; settings = {ATTRIBUTES = (Private, ); }; };
32E67312235765B500DB4987 /* SDDisplayLink.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E67310235765B500DB4987 /* SDDisplayLink.m */; };
@ -315,6 +317,7 @@
dstPath = include/SDWebImage;
dstSubfolderSpec = 16;
files = (
32D9EE4B24AF259B00EAFDF4 /* SDImageAWebPCoder.h in Copy Headers */,
328E9DE523A61DD30051C893 /* SDGraphicsImageRenderer.h in Copy Headers */,
325F7CCD2389467800AEDFCC /* UIImage+ExtendedCacheData.h in Copy Headers */,
326E2F36236F1E30006F847F /* SDAnimatedImagePlayer.h in Copy Headers */,
@ -435,15 +438,17 @@
325F7CC523893B2E00AEDFCC /* SDFileAttributeHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDFileAttributeHelper.m; sourceTree = "<group>"; };
325F7CC8238942AB00AEDFCC /* UIImage+ExtendedCacheData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UIImage+ExtendedCacheData.h"; path = "Core/UIImage+ExtendedCacheData.h"; sourceTree = "<group>"; };
325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "UIImage+ExtendedCacheData.m"; path = "Core/UIImage+ExtendedCacheData.m"; sourceTree = "<group>"; };
3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDImageAWebPCoder.h; path = Core/SDImageAWebPCoder.h; sourceTree = "<group>"; };
3263626D24AEEEB0008FB119 /* SDImageAWebPCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDImageAWebPCoder.m; path = Core/SDImageAWebPCoder.m; sourceTree = "<group>"; };
326E2F2C236F0B23006F847F /* SDAnimatedImagePlayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDAnimatedImagePlayer.h; path = Core/SDAnimatedImagePlayer.h; sourceTree = "<group>"; };
326E2F2D236F0B23006F847F /* SDAnimatedImagePlayer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDAnimatedImagePlayer.m; path = Core/SDAnimatedImagePlayer.m; sourceTree = "<group>"; };
326E2F31236F1D58006F847F /* SDDeviceHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDDeviceHelper.h; sourceTree = "<group>"; };
326E2F32236F1D58006F847F /* SDDeviceHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDDeviceHelper.m; sourceTree = "<group>"; };
327054D2206CD8B3006EA328 /* SDImageAPNGCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDImageAPNGCoder.h; path = Core/SDImageAPNGCoder.h; sourceTree = "<group>"; };
327054D3206CD8B3006EA328 /* SDImageAPNGCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDImageAPNGCoder.m; path = Core/SDImageAPNGCoder.m; sourceTree = "<group>"; };
327F2E82245AE1650075F846 /* SDWebImageOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDWebImageOperation.m; path = Core/SDWebImageOperation.m; sourceTree = "<group>"; };
3287E6CD244C0C1400007311 /* MKAnnotationView+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MKAnnotationView+WebCache.m"; sourceTree = "<group>"; };
3287E6CE244C0C1400007311 /* MKAnnotationView+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MKAnnotationView+WebCache.h"; sourceTree = "<group>"; };
327F2E82245AE1650075F846 /* SDWebImageOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDWebImageOperation.m; path = Core/SDWebImageOperation.m; sourceTree = "<group>"; };
328BB69A2081FED200760D6C /* SDWebImageCacheKeyFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDWebImageCacheKeyFilter.h; path = Core/SDWebImageCacheKeyFilter.h; sourceTree = "<group>"; };
328BB69B2081FED200760D6C /* SDWebImageCacheKeyFilter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDWebImageCacheKeyFilter.m; path = Core/SDWebImageCacheKeyFilter.m; sourceTree = "<group>"; };
328BB6A82081FEE500760D6C /* SDWebImageCacheSerializer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDWebImageCacheSerializer.h; path = Core/SDWebImageCacheSerializer.h; sourceTree = "<group>"; };
@ -456,7 +461,6 @@
3290FA031FA478AF0047D20C /* SDImageFrame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDImageFrame.m; path = Core/SDImageFrame.m; sourceTree = "<group>"; };
3298655A2337230C0071958B /* SDImageHEICCoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDImageHEICCoder.h; path = Core/SDImageHEICCoder.h; sourceTree = "<group>"; };
3298655B2337230C0071958B /* SDImageHEICCoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDImageHEICCoder.m; path = Core/SDImageHEICCoder.m; sourceTree = "<group>"; };
32986560233737C70071958B /* SDImageHEICCoderInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDImageHEICCoderInternal.h; sourceTree = "<group>"; };
329A18571FFF5DFD008C9A2F /* UIImage+Metadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+Metadata.h"; path = "Core/UIImage+Metadata.h"; sourceTree = "<group>"; };
329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+Metadata.m"; path = "Core/UIImage+Metadata.m"; sourceTree = "<group>"; };
329F1235223FAA3B00B309FD /* SDmetamacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDmetamacros.h; sourceTree = "<group>"; };
@ -583,6 +587,8 @@
327054D3206CD8B3006EA328 /* SDImageAPNGCoder.m */,
3298655A2337230C0071958B /* SDImageHEICCoder.h */,
3298655B2337230C0071958B /* SDImageHEICCoder.m */,
3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */,
3263626D24AEEEB0008FB119 /* SDImageAWebPCoder.m */,
3290FA021FA478AF0047D20C /* SDImageFrame.h */,
3290FA031FA478AF0047D20C /* SDImageFrame.m */,
32CF1C051FA496B000004BD1 /* SDImageCoderHelper.h */,
@ -680,7 +686,6 @@
325C460C223394D8004CAE11 /* SDImageCachesManagerOperation.h */,
325C460D223394D8004CAE11 /* SDImageCachesManagerOperation.m */,
32C78E39233371AD00C6B7F8 /* SDImageIOAnimatedCoderInternal.h */,
32986560233737C70071958B /* SDImageHEICCoderInternal.h */,
3253F235244982D3006C2BE8 /* SDWebImageTransitionInternal.h */,
325C461E2233A02E004CAE11 /* UIColor+SDHexString.h */,
325C461F2233A02E004CAE11 /* UIColor+SDHexString.m */,
@ -889,7 +894,6 @@
buildActionMask = 2147483647;
files = (
32B5CC60222F89C2005EB74E /* SDAsyncBlockOperation.h in Headers */,
32986562233737C70071958B /* SDImageHEICCoderInternal.h in Headers */,
32D122202080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
3298655C2337230C0071958B /* SDImageHEICCoder.h in Headers */,
32B9B539206ED4230026769D /* SDWebImageDownloaderConfig.h in Headers */,
@ -939,6 +943,7 @@
32484777201775F600AF9E5A /* SDAnimatedImage.h in Headers */,
325C460922339426004CAE11 /* SDWeakProxy.h in Headers */,
80B6DF812142B43B00BCB334 /* SDAnimatedImageRep.h in Headers */,
3263626E24AEEEB0008FB119 /* SDImageAWebPCoder.h in Headers */,
4A2CAE2F1AB4BB7500B6BC39 /* UIImage+MultiFormat.h in Headers */,
325C46212233A02E004CAE11 /* UIColor+SDHexString.h in Headers */,
325312CA200F09910046BF1E /* SDWebImageTransition.h in Headers */,
@ -1154,6 +1159,7 @@
3246A70523A567AC00FBEA10 /* SDGraphicsImageRenderer.m in Sources */,
321E60C61F38E91700405457 /* UIImage+ForceDecode.m in Sources */,
3244062E2296C5F400A36084 /* SDWebImageOptionsProcessor.m in Sources */,
3263626F24AEEEB0008FB119 /* SDImageAWebPCoder.m in Sources */,
3250C9F02355D9DA0093A896 /* SDWebImageDownloaderDecryptor.m in Sources */,
328BB6A42081FED200760D6C /* SDWebImageCacheKeyFilter.m in Sources */,
32E67313235765B500DB4987 /* SDDisplayLink.m in Sources */,

View File

@ -13,10 +13,8 @@
#else
#import <MobileCoreServices/MobileCoreServices.h>
#endif
#import "SDImageHEICCoderInternal.h"
#import "SDImageIOAnimatedCoderInternal.h"
// Currently Image/IO does not support WebP
#define kSDUTTypeWebP ((__bridge CFStringRef)@"public.webp")
#define kSVGTagEnd @"</svg>"
@implementation NSData (ImageContentType)

View File

@ -14,7 +14,7 @@
#import "SDImageGIFCoder.h"
#import "SDImageAPNGCoder.h"
#import "SDImageHEICCoder.h"
#import "SDImageHEICCoderInternal.h"
#import "SDImageAWebPCoder.h"
@implementation SDAnimatedImageRep {
CGImageSourceRef _imageSource;
@ -34,6 +34,8 @@
}
// We should override init method for `NSBitmapImageRep` to do initialize about animated image format
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
- (instancetype)initWithData:(NSData *)data {
self = [super initWithData:data];
if (self) {
@ -70,6 +72,13 @@
[self setProperty:NSImageCurrentFrame withValue:@(0)];
NSUInteger loopCount = [SDImageHEICCoder imageLoopCountWithSource:imageSource];
[self setProperty:NSImageLoopCount withValue:@(loopCount)];
} else if (CFStringCompare(type, kSDUTTypeWebP, 0) == kCFCompareEqualTo) {
// WebP
// Do initialize about frame count, current frame/duration and loop count
[self setProperty:NSImageFrameCount withValue:@(frameCount)];
[self setProperty:NSImageCurrentFrame withValue:@(0)];
NSUInteger loopCount = [SDImageAWebPCoder imageLoopCountWithSource:imageSource];
[self setProperty:NSImageLoopCount withValue:@(loopCount)];
}
}
return self;
@ -100,6 +109,9 @@
} else if (CFStringCompare(type, kSDUTTypeHEICS, 0) == kCFCompareEqualTo) {
// HEIC
frameDuration = [SDImageHEICCoder frameDurationAtIndex:index source:imageSource];
} else if (CFStringCompare(type, kSDUTTypeWebP, 0) == kCFCompareEqualTo) {
// WebP
frameDuration = [SDImageAWebPCoder frameDurationAtIndex:index source:imageSource];
}
if (!frameDuration) {
return;
@ -108,6 +120,7 @@
[super setProperty:NSImageCurrentFrameDuration withValue:@(frameDuration)];
}
}
#pragma clang diagnostic pop
@end

View File

@ -0,0 +1,23 @@
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <Foundation/Foundation.h>
#import "SDImageIOAnimatedCoder.h"
/**
This coder is used for Google WebP and Animated WebP(AWebP) image format.
Image/IO provide the WebP decoding support in iOS 14/macOS 11/tvOS 14/watchOS 7+.
@note Currently Image/IO seems does not supports WebP encoding, if you need WebP encoding, use the custom codec below.
@note If you need to support lower firmware version for WebP, you can have a try at https://github.com/SDWebImage/SDWebImageWebPCoder
*/
API_AVAILABLE(ios(14.0), tvos(14.0), macos(11.0), watchos(7.0))
@interface SDImageAWebPCoder : SDImageIOAnimatedCoder <SDProgressiveImageCoder, SDAnimatedImageCoder>
@property (nonatomic, class, readonly, nonnull) SDImageAWebPCoder *sharedCoder;
@end

View File

@ -0,0 +1,98 @@
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "SDImageAWebPCoder.h"
#import "SDImageIOAnimatedCoderInternal.h"
// These constants are available from iOS 14+ and Xcode 12. This raw value is used for toolchain and firmware compatibility
static NSString * kSDCGImagePropertyWebPDictionary = @"{WebP}";
static NSString * kSDCGImagePropertyWebPLoopCount = @"LoopCount";
static NSString * kSDCGImagePropertyWebPDelayTime = @"DelayTime";
static NSString * kSDCGImagePropertyWebPUnclampedDelayTime = @"UnclampedDelayTime";
@implementation SDImageAWebPCoder
+ (void)initialize {
#if __IPHONE_14_0 || __TVOS_14_0 || __MAC_11_0 || __WATCHOS_7_0
// Xcode 12
if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) {
// Use SDK instead of raw value
kSDCGImagePropertyWebPDictionary = (__bridge NSString *)kCGImagePropertyWebPDictionary;
kSDCGImagePropertyWebPLoopCount = (__bridge NSString *)kCGImagePropertyWebPLoopCount;
kSDCGImagePropertyWebPDelayTime = (__bridge NSString *)kCGImagePropertyWebPDelayTime;
kSDCGImagePropertyWebPUnclampedDelayTime = (__bridge NSString *)kCGImagePropertyWebPUnclampedDelayTime;
}
#endif
}
+ (instancetype)sharedCoder {
static SDImageAWebPCoder *coder;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
coder = [[SDImageAWebPCoder alloc] init];
});
return coder;
}
#pragma mark - SDImageCoder
- (BOOL)canDecodeFromData:(nullable NSData *)data {
switch ([NSData sd_imageFormatForImageData:data]) {
case SDImageFormatWebP:
// Check WebP decoding compatibility
return [self.class canDecodeFromFormat:SDImageFormatWebP];
default:
return NO;
}
}
- (BOOL)canIncrementalDecodeFromData:(NSData *)data {
return [self canDecodeFromData:data];
}
- (BOOL)canEncodeToFormat:(SDImageFormat)format {
switch (format) {
case SDImageFormatWebP:
// Check WebP encoding compatibility
return [self.class canEncodeToFormat:SDImageFormatWebP];
default:
return NO;
}
}
#pragma mark - Subclass Override
+ (SDImageFormat)imageFormat {
return SDImageFormatWebP;
}
+ (NSString *)imageUTType {
return (__bridge NSString *)kSDUTTypeWebP;
}
+ (NSString *)dictionaryProperty {
return kSDCGImagePropertyWebPDictionary;
}
+ (NSString *)unclampedDelayTimeProperty {
return kSDCGImagePropertyWebPUnclampedDelayTime;
}
+ (NSString *)delayTimeProperty {
return kSDCGImagePropertyWebPDelayTime;
}
+ (NSString *)loopCountProperty {
return kSDCGImagePropertyWebPLoopCount;
}
+ (NSUInteger)defaultLoopCount {
return 0;
}
@end

View File

@ -17,6 +17,7 @@
@note This coder is not in the default coder list for now, since HEIC animated image is really rare, and Apple's implementation still contains performance issues. You can enable if you need this.
@note If you need to support lower firmware version for HEIF, you can have a try at https://github.com/SDWebImage/SDWebImageHEIFCoder
*/
API_AVAILABLE(ios(13.0), tvos(13.0), macos(10.15), watchos(6.0))
@interface SDImageHEICCoder : SDImageIOAnimatedCoder <SDProgressiveImageCoder, SDAnimatedImageCoder>
@property (nonatomic, class, readonly, nonnull) SDImageHEICCoder *sharedCoder;

View File

@ -7,7 +7,7 @@
*/
#import "SDImageHEICCoder.h"
#import "SDImageHEICCoderInternal.h"
#import "SDImageIOAnimatedCoderInternal.h"
// These constants are available from iOS 13+ and Xcode 11. This raw value is used for toolchain and firmware compatibility
static NSString * kSDCGImagePropertyHEICSDictionary = @"{HEICS}";
@ -45,10 +45,10 @@ static NSString * kSDCGImagePropertyHEICSUnclampedDelayTime = @"UnclampedDelayTi
switch ([NSData sd_imageFormatForImageData:data]) {
case SDImageFormatHEIC:
// Check HEIC decoding compatibility
return [self.class canDecodeFromHEICFormat];
return [self.class canDecodeFromFormat:SDImageFormatHEIC];
case SDImageFormatHEIF:
// Check HEIF decoding compatibility
return [self.class canDecodeFromHEIFFormat];
return [self.class canDecodeFromFormat:SDImageFormatHEIF];
default:
return NO;
}
@ -62,78 +62,15 @@ static NSString * kSDCGImagePropertyHEICSUnclampedDelayTime = @"UnclampedDelayTi
switch (format) {
case SDImageFormatHEIC:
// Check HEIC encoding compatibility
return [self.class canEncodeToHEICFormat];
return [self.class canEncodeToFormat:SDImageFormatHEIC];
case SDImageFormatHEIF:
// Check HEIF encoding compatibility
return [self.class canEncodeToHEIFFormat];
return [self.class canEncodeToFormat:SDImageFormatHEIF];
default:
return NO;
}
}
#pragma mark - HEIF Format
+ (BOOL)canDecodeFromFormat:(SDImageFormat)format {
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageSourceCopyTypeIdentifiers();
if ([imageUTTypes containsObject:(__bridge NSString *)(imageUTType)]) {
return YES;
}
return NO;
}
+ (BOOL)canDecodeFromHEICFormat {
static BOOL canDecode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
canDecode = [self canDecodeFromFormat:SDImageFormatHEIC];
});
return canDecode;
}
+ (BOOL)canDecodeFromHEIFFormat {
static BOOL canDecode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
canDecode = [self canDecodeFromFormat:SDImageFormatHEIF];
});
return canDecode;
}
+ (BOOL)canEncodeToFormat:(SDImageFormat)format {
NSMutableData *imageData = [NSMutableData data];
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
// Create an image destination.
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL);
if (!imageDestination) {
// Can't encode to HEIC
return NO;
} else {
// Can encode to HEIC
CFRelease(imageDestination);
return YES;
}
}
+ (BOOL)canEncodeToHEICFormat {
static BOOL canEncode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
canEncode = [self canEncodeToFormat:SDImageFormatHEIC];
});
return canEncode;
}
+ (BOOL)canEncodeToHEIFFormat {
static BOOL canEncode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
canEncode = [self canEncodeToFormat:SDImageFormatHEIF];
});
return canEncode;
}
#pragma mark - Subclass Override
+ (SDImageFormat)imageFormat {

View File

@ -108,6 +108,36 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
#pragma mark - Utils
+ (BOOL)canDecodeFromFormat:(SDImageFormat)format {
static dispatch_once_t onceToken;
static NSSet *imageUTTypeSet;
dispatch_once(&onceToken, ^{
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageSourceCopyTypeIdentifiers();
imageUTTypeSet = [NSSet setWithArray:imageUTTypes];
});
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
if ([imageUTTypeSet containsObject:(__bridge NSString *)(imageUTType)]) {
// Can decode from target format
return YES;
}
return NO;
}
+ (BOOL)canEncodeToFormat:(SDImageFormat)format {
static dispatch_once_t onceToken;
static NSSet *imageUTTypeSet;
dispatch_once(&onceToken, ^{
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageDestinationCopyTypeIdentifiers();
imageUTTypeSet = [NSSet setWithArray:imageUTTypes];
});
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
if ([imageUTTypeSet containsObject:(__bridge NSString *)(imageUTType)]) {
// Can encode to target format
return YES;
}
return NO;
}
+ (NSUInteger)imageLoopCountWithSource:(CGImageSourceRef)source {
NSUInteger loopCount = self.defaultLoopCount;
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil);

View File

@ -11,7 +11,6 @@
#import "NSImage+Compatibility.h"
#import <ImageIO/ImageIO.h>
#import "UIImage+Metadata.h"
#import "SDImageHEICCoderInternal.h"
#import "SDImageIOAnimatedCoderInternal.h"
// Specify File Size for lossy format encoding, like JPEG
@ -55,19 +54,7 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
#pragma mark - Decode
- (BOOL)canDecodeFromData:(nullable NSData *)data {
switch ([NSData sd_imageFormatForImageData:data]) {
case SDImageFormatWebP:
// Do not support WebP decoding
return NO;
case SDImageFormatHEIC:
// Check HEIC decoding compatibility
return [SDImageHEICCoder canDecodeFromHEICFormat];
case SDImageFormatHEIF:
// Check HEIF decoding compatibility
return [SDImageHEICCoder canDecodeFromHEIFFormat];
default:
return YES;
}
return YES;
}
- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDImageCoderOptions *)options {
@ -205,19 +192,7 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
#pragma mark - Encode
- (BOOL)canEncodeToFormat:(SDImageFormat)format {
switch (format) {
case SDImageFormatWebP:
// Do not support WebP encoding
return NO;
case SDImageFormatHEIC:
// Check HEIC encoding compatibility
return [SDImageHEICCoder canEncodeToHEICFormat];
case SDImageFormatHEIF:
// Check HEIF encoding compatibility
return [SDImageHEICCoder canEncodeToHEIFFormat];
default:
return YES;
}
return YES;
}
- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDImageCoderOptions *)options {

View File

@ -1,25 +0,0 @@
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <Foundation/Foundation.h>
#import "SDImageHEICCoder.h"
// AVFileTypeHEIC/AVFileTypeHEIF is defined in AVFoundation via iOS 11, we use this without import AVFoundation
#define kSDUTTypeHEIC ((__bridge CFStringRef)@"public.heic")
#define kSDUTTypeHEIF ((__bridge CFStringRef)@"public.heif")
// HEIC Sequence (Animated Image)
#define kSDUTTypeHEICS ((__bridge CFStringRef)@"public.heics")
@interface SDImageHEICCoder ()
+ (BOOL)canDecodeFromHEICFormat;
+ (BOOL)canDecodeFromHEIFFormat;
+ (BOOL)canEncodeToHEICFormat;
+ (BOOL)canEncodeToHEIFFormat;
@end

View File

@ -9,10 +9,20 @@
#import <Foundation/Foundation.h>
#import "SDImageIOAnimatedCoder.h"
// AVFileTypeHEIC/AVFileTypeHEIF is defined in AVFoundation via iOS 11, we use this without import AVFoundation
#define kSDUTTypeHEIC ((__bridge CFStringRef)@"public.heic")
#define kSDUTTypeHEIF ((__bridge CFStringRef)@"public.heif")
// HEIC Sequence (Animated Image)
#define kSDUTTypeHEICS ((__bridge CFStringRef)@"public.heics")
// kUTTypeWebP seems not defined in public UTI framework, Apple use the hardcode string, we define them :)
#define kSDUTTypeWebP ((__bridge CFStringRef)@"org.webmproject.webp")
@interface SDImageIOAnimatedCoder ()
+ (NSTimeInterval)frameDurationAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source;
+ (NSUInteger)imageLoopCountWithSource:(nonnull CGImageSourceRef)source;
+ (nullable UIImage *)createFrameAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source scale:(CGFloat)scale preserveAspectRatio:(BOOL)preserveAspectRatio thumbnailSize:(CGSize)thumbnailSize options:(nullable NSDictionary *)options;
+ (BOOL)canEncodeToFormat:(SDImageFormat)format;
+ (BOOL)canDecodeFromFormat:(SDImageFormat)format;
@end

View File

@ -0,0 +1 @@
../../Core/SDImageAWebPCoder.h

View File

@ -24,6 +24,12 @@
323B8E2020862322008952BE /* SDWebImageTestLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 323B8E1E20862322008952BE /* SDWebImageTestLoader.m */; };
324047442271956F007C53E1 /* TestEXIF.png in Resources */ = {isa = PBXBuildFile; fileRef = 324047432271956F007C53E1 /* TestEXIF.png */; };
324047452271956F007C53E1 /* TestEXIF.png in Resources */ = {isa = PBXBuildFile; fileRef = 324047432271956F007C53E1 /* TestEXIF.png */; };
32515F9924AF1919005E8F79 /* TestImageStatic.webp in Resources */ = {isa = PBXBuildFile; fileRef = 32515F9724AF1919005E8F79 /* TestImageStatic.webp */; };
32515F9A24AF1919005E8F79 /* TestImageStatic.webp in Resources */ = {isa = PBXBuildFile; fileRef = 32515F9724AF1919005E8F79 /* TestImageStatic.webp */; };
32515F9B24AF1919005E8F79 /* TestImageStatic.webp in Resources */ = {isa = PBXBuildFile; fileRef = 32515F9724AF1919005E8F79 /* TestImageStatic.webp */; };
32515F9C24AF1919005E8F79 /* TestImageAnimated.webp in Resources */ = {isa = PBXBuildFile; fileRef = 32515F9824AF1919005E8F79 /* TestImageAnimated.webp */; };
32515F9D24AF1919005E8F79 /* TestImageAnimated.webp in Resources */ = {isa = PBXBuildFile; fileRef = 32515F9824AF1919005E8F79 /* TestImageAnimated.webp */; };
32515F9E24AF1919005E8F79 /* TestImageAnimated.webp in Resources */ = {isa = PBXBuildFile; fileRef = 32515F9824AF1919005E8F79 /* TestImageAnimated.webp */; };
3254C32020641077008D1022 /* SDImageTransformerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3254C31F20641077008D1022 /* SDImageTransformerTests.m */; };
3254C32120641077008D1022 /* SDImageTransformerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3254C31F20641077008D1022 /* SDImageTransformerTests.m */; };
3264FF2F205D42CB00F6BD48 /* SDWebImageTestTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3264FF2E205D42CB00F6BD48 /* SDWebImageTestTransformer.m */; };
@ -118,6 +124,8 @@
323B8E1D20862322008952BE /* SDWebImageTestLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestLoader.h; sourceTree = "<group>"; };
323B8E1E20862322008952BE /* SDWebImageTestLoader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestLoader.m; sourceTree = "<group>"; };
324047432271956F007C53E1 /* TestEXIF.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TestEXIF.png; sourceTree = "<group>"; };
32515F9724AF1919005E8F79 /* TestImageStatic.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestImageStatic.webp; sourceTree = "<group>"; };
32515F9824AF1919005E8F79 /* TestImageAnimated.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestImageAnimated.webp; sourceTree = "<group>"; };
3254C31F20641077008D1022 /* SDImageTransformerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDImageTransformerTests.m; sourceTree = "<group>"; };
3264FF2D205D42CB00F6BD48 /* SDWebImageTestTransformer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestTransformer.h; sourceTree = "<group>"; };
3264FF2E205D42CB00F6BD48 /* SDWebImageTestTransformer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestTransformer.m; sourceTree = "<group>"; };
@ -250,6 +258,8 @@
3234306123E2BAC800C290C8 /* TestImage.pdf */,
327054E1206CEFF3006EA328 /* TestImageAnimated.apng */,
3297A09E23374D1600814590 /* TestImageAnimated.heic */,
32515F9824AF1919005E8F79 /* TestImageAnimated.webp */,
32515F9724AF1919005E8F79 /* TestImageStatic.webp */,
);
path = Images;
sourceTree = "<group>";
@ -459,7 +469,9 @@
3299228A2365DC6C00EAFD97 /* TestImage.png in Resources */,
329922842365DC6C00EAFD97 /* MonochromeTestImage.jpg in Resources */,
329922882365DC6C00EAFD97 /* TestImage.jpg in Resources */,
32515F9E24AF1919005E8F79 /* TestImageAnimated.webp in Resources */,
3299228E2365DC6C00EAFD97 /* TestImageAnimated.heic in Resources */,
32515F9B24AF1919005E8F79 /* TestImageStatic.webp in Resources */,
329922862365DC6C00EAFD97 /* TestImage.gif in Resources */,
329922852365DC6C00EAFD97 /* TestEXIF.png in Resources */,
);
@ -479,7 +491,9 @@
3297A0A023374D1700814590 /* TestImageAnimated.heic in Resources */,
32B99EA2203B31360017FD66 /* MonochromeTestImage.jpg in Resources */,
32905E65211D786E00460FCF /* TestImage.heif in Resources */,
32515F9D24AF1919005E8F79 /* TestImageAnimated.webp in Resources */,
327A418D211D660600495442 /* TestImage.heic in Resources */,
32515F9A24AF1919005E8F79 /* TestImageStatic.webp in Resources */,
326E69482334C0C300B7252C /* TestLoopCount.gif in Resources */,
32B99EA5203B31360017FD66 /* TestImageLarge.jpg in Resources */,
);
@ -499,7 +513,9 @@
433BBBB91D7EF8260086B6E9 /* TestImage.png in Resources */,
3297A09F23374D1700814590 /* TestImageAnimated.heic in Resources */,
327054E2206CEFF3006EA328 /* TestImageAnimated.apng in Resources */,
32515F9C24AF1919005E8F79 /* TestImageAnimated.webp in Resources */,
326E69472334C0C300B7252C /* TestLoopCount.gif in Resources */,
32515F9924AF1919005E8F79 /* TestImageStatic.webp in Resources */,
433BBBBB1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg in Resources */,
324047442271956F007C53E1 /* TestEXIF.png in Resources */,
);

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -169,7 +169,7 @@
}
- (void)test13ThatHEICWorks {
if (@available(iOS 11, macOS 10.13, *)) {
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"];
#if SD_UIKIT
BOOL supportsEncoding = YES; // iPhone Simulator after Xcode 9.3 support HEIC encoding
@ -184,7 +184,7 @@
}
- (void)test14ThatHEIFWorks {
if (@available(iOS 11, macOS 10.13, *)) {
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
NSURL *heifURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heif"];
[self verifyCoder:[SDImageIOCoder sharedCoder]
withLocalImageURL:heifURL
@ -198,12 +198,12 @@
manager.coders = @[SDImageIOCoder.sharedCoder];
expect([manager canDecodeFromData:nil]).beTruthy(); // Image/IO will return YES for future format
expect([manager decodedImageWithData:nil options:nil]).beNil();
expect([manager canEncodeToFormat:SDImageFormatWebP]).beFalsy();
expect([manager canEncodeToFormat:SDImageFormatUndefined]).beTruthy(); // Image/IO will return YES for future format
expect([manager encodedDataWithImage:nil format:SDImageFormatUndefined options:nil]).beNil();
}
- (void)test16ThatHEICAnimatedWorks {
if (@available(iOS 11, macOS 10.13, *)) {
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"heic"];
#if SD_UIKIT
BOOL isAnimatedImage = YES;
@ -231,7 +231,31 @@
isVectorImage:YES];
}
- (void)test18ThatImageIOAnimatedCoderAbstractClass {
- (void)test18ThatStaticWebPWorks {
if (@available(iOS 14, tvOS 14, macOS 11, *)) {
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"];
[self verifyCoder:[SDImageAWebPCoder sharedCoder]
withLocalImageURL:staticWebPURL
supportsEncoding:NO // Currently (iOS 14.0) seems no encoding support
encodingFormat:SDImageFormatWebP
isAnimatedImage:NO
isVectorImage:NO];
}
}
- (void)test19ThatAnimatedWebPWorks {
if (@available(iOS 14, tvOS 14, macOS 11, *)) {
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"webp"];
[self verifyCoder:[SDImageAWebPCoder sharedCoder]
withLocalImageURL:staticWebPURL
supportsEncoding:NO // Currently (iOS 14.0) seems no encoding support
encodingFormat:SDImageFormatWebP
isAnimatedImage:YES
isVectorImage:NO];
}
}
- (void)test20ThatImageIOAnimatedCoderAbstractClass {
SDImageIOAnimatedCoder *coder = [[SDImageIOAnimatedCoder alloc] init];
@try {
[coder canEncodeToFormat:SDImageFormatPNG];
@ -241,8 +265,8 @@
}
}
- (void)test19ThatEmbedThumbnailHEICWorks {
if (@available(iOS 11, macOS 10.13, *)) {
- (void)test21ThatEmbedThumbnailHEICWorks {
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
// The input HEIC does not contains any embed thumbnail
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"];
CGImageSourceRef source = CGImageSourceCreateWithURL((__bridge CFURLRef)heicURL, nil);

View File

@ -70,6 +70,7 @@ FOUNDATION_EXPORT const unsigned char SDWebImageVersionString[];
#import <SDWebImage/SDWebImageOptionsProcessor.h>
#import <SDWebImage/SDImageIOAnimatedCoder.h>
#import <SDWebImage/SDImageHEICCoder.h>
#import <SDWebImage/SDImageAWebPCoder.h>
// Mac
#if __has_include(<SDWebImage/NSImage+Compatibility.h>)