     return imageProperties[String(kCGImagePropertyGIFDictionary)] as? GIFProperties
   }
 }
+
 #endif

import UIKit

typealias GIFProperties = [String: Double]
let defaultDuration: Double = 0

/// Retruns the duration of a frame at a specific index using an image source (an `CGImageSource` instance).
///
/// - returns: A frame duration.
func CGImageFrameDuration(with imageSource: CGImageSource, atIndex index: Int) -> TimeInterval {
  if !imageSource.isAnimatedGIF { return 0.0 }

  guard let GIFProperties = imageSource.properties(at: index),
    let duration = frameDuration(with: GIFProperties),
    let cappedDuration = capDuration(with: duration)
    else { return defaultDuration }

  return cappedDuration
}

/// Ensures that a duration is never smaller than a threshold value.
///
/// - returns: A capped frame duration.
func capDuration(with duration: Double) -> Double? {
  if duration < 0 { return nil }
  let threshold = 0.02 - Double.ulpOfOne
  let cappedDuration = duration < threshold ? 0.1 : duration
  return cappedDuration
}


    let imageCount = CGImageSourceGetCount(self)
    return isTypeGIF != false && imageCount > 1
  }
  
  /// Returns the GIF properties at a specific index.
  ///
  /// - parameter index: The index of the GIF properties to retrieve.
