     private func layoutShadow() {
 
         generateBlurBackground()
+        guard let image = image else {
+            return
+        }
 
         let realImageSize = getRealImageSize(image)
 


    /// 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
        }
    }

