 
     /// Adds rounded corners with the given radius to the image.
     /// - parameter radius: Radius in pixels.
-    func byAddingRoundedCorners(radius: CGFloat) -> Image? {
+    /// - parameter color: Pass a color to stroke a border.
+    func byAddingRoundedCorners(radius: CGFloat, color: UIColor? = nil) -> Image? {
         guard let cgImage = image.cgImage else {
             return nil
         }

// MARK: - ImageProcessor.RoundedCorners

extension ImageProcessor {

    /// Rounds the corners of an image to the specified radius.
    ///
    /// - warning: In order for the corners to be displayed correctly, the image must exactly match the size
    /// of the image view in which it will be displayed. See `ImageProcessor.Resize` for more info.
    public struct RoundedCorners: ImageProcessing, Hashable, CustomStringConvertible {
        private let radius: CGFloat
        private let unit: Unit

        /// Initializes the processor with the given radius.
        ///
        /// - parameter radius: The radius of the corners.
        /// - parameter unit: Unit of the radius, `.points` by default.
        public init(radius: CGFloat, unit: Unit = .points) {
            self.radius = radius
            self.unit = unit
        }

        public func process(image: Image, context: ImageProcessingContext?) -> Image? {
            return image.processed.byAddingRoundedCorners(radius: radius.converted(to: unit))
        }

        public var identifier: String {
            return "com.github.kean/nuke/rounded_corners?radius=\(radius.converted(to: unit))"
        }

        public var hashableIdentifier: AnyHashable {

        UIGraphicsBeginImageContextWithOptions(imageSize, false, 1.0)
        defer { UIGraphicsEndImageContext() }

        let rect = CGRect(origin: CGPoint.zero, size: imageSize)
        let clippingPath = UIBezierPath(roundedRect: rect, cornerRadius: radius)
      
        clippingPath.addClip()
        image.draw(in: CGRect(origin: CGPoint.zero, size: imageSize))
        
        if let cgColor = color?.cgColor {
            UIGraphicsGetCurrentContext()?.setStrokeColor(cgColor)
          
            let border = UIBezierPath(roundedRect: rect, cornerRadius: radius)
          
            border.stroke()
        }

        guard let roundedImage = UIGraphicsGetImageFromCurrentImageContext()?.cgImage else {
            return nil
        }
      
        return UIImage(cgImage: roundedImage, scale: image.scale, orientation: image.imageOrientation)
    }

