From e1b4e5a2d414159a82781554d87f4b92a77b7467 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 29 May 2019 12:37:50 +0800 Subject: [PATCH] Fix that `CGImageDestinationCreateWithData` 0 count arg will log a warning, this does not effect the encoding function. --- SDWebImage/SDImageAPNGCoder.m | 3 ++- SDWebImage/SDImageGIFCoder.m | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SDWebImage/SDImageAPNGCoder.m b/SDWebImage/SDImageAPNGCoder.m index d816bcc2..3c699843 100644 --- a/SDWebImage/SDImageAPNGCoder.m +++ b/SDWebImage/SDImageAPNGCoder.m @@ -193,7 +193,8 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef NSArray *frames = [SDImageCoderHelper framesFromAnimatedImage:image]; // Create an image destination. APNG does not support EXIF image orientation - CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count, NULL); + // The `CGImageDestinationCreateWithData` will log a warning when count is 0, use 1 instead. + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count ?: 1, NULL); if (!imageDestination) { // Handle failure. return nil; diff --git a/SDWebImage/SDImageGIFCoder.m b/SDWebImage/SDImageGIFCoder.m index 6668c20a..d14aa93b 100644 --- a/SDWebImage/SDImageGIFCoder.m +++ b/SDWebImage/SDImageGIFCoder.m @@ -269,7 +269,8 @@ NSArray *frames = [SDImageCoderHelper framesFromAnimatedImage:image]; // Create an image destination. GIF does not support EXIF image orientation - CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count, NULL); + // The `CGImageDestinationCreateWithData` will log a warning when count is 0, use 1 instead. + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count ?: 1, NULL); if (!imageDestination) { // Handle failure. return nil;