             guard let weakself = self else {
                 return
             }
-
-            let realImageSize = weakself.getRealImageSize(weakself.image)
+            guard let image = weakself.image else{
+                return
+            }
+            let realImageSize = weakself.getRealImageSize(image)
             // Create a containerView to hold the image should apply gaussian blur.
             let containerView = UIView(frame: CGRect(origin: .zero, size: realImageSize.scaled(by: 1.4)))
             containerView.backgroundColor = .clear
             let blurImageView = UIImageView(frame: CGRect(origin: .zero, size: realImageSize))
             blurImageView.center = containerView.center
-            blurImageView.image = weakself.image
+            blurImageView.image = image
             blurImageView.layer.cornerRadius = weakself.imageCornerRaidus
             blurImageView.layer.masksToBounds = true
             containerView.addSubview(blurImageView)
-
+            
+            var containerImage = UIImage()
             // Get the UIImage from a UIView.
-            let containerImage = UIImage(view: containerView)
+            if containerView.frame.size != CGSize.zero {
+                containerImage = UIImage(view: containerView)
+            }else {
+                containerImage = UIImage()
+            }
 
             guard let resizedContainerImage = containerImage.resized(withPercentage: 0.2),
                 let ciimage = CIImage(image: resizedContainerImage),


    /// The image view contains target image
    @IBInspectable
    public var image: UIImage {
        set {
            imageView.image = newValue
            layoutShadow()
        }
        get {
            return imageView.image ?? UIImage()
        }
    }


    /// - Returns: the real size of the image
    func getRealImageSize(_ from: UIImage) -> CGSize {
        if contentMode == .scaleAspectFit {
            let scale = min(bounds.size.width / from.size.width, bounds.size.height / from.size.height)
            return from.size.scaled(by: scale)
        } else {
            return from.size
        }
    }

