         let imageView = currentContentView
         return convert(imageView?.frame ?? .zero, from: imageView?.superview)
     }
+    
+    
+    private var videoSize: CGSize = .zero
+
+    private var minimumZoomScale: CGFloat {
+        if image == nil && videoPlayerItem == nil {
+            if #available(iOS 9.1, *) {
+                if livePhoto == nil {
+                    return 1
+                }
+            } else {
+                return 1
+            }
+        }
+
+        let viewport = finalViewportRect
+        var mediaSize: CGSize = .zero
+        if let image = image {
+            mediaSize = image.size
+        } else if videoPlayerItem != nil {
+            mediaSize = videoSize
+        }
+        if #available(iOS 9.1, *) {
+            if let livePhoto = livePhoto {
+                mediaSize = livePhoto.size
+            }
+        }
+
+        var minScale: CGFloat = 1
+        let scaleX = viewport.width / mediaSize.width
+        let scaleY = viewport.height / mediaSize.height
+        if contentMode == .scaleAspectFit {
+            minScale = min(scaleX, scaleY)
+        } else if contentMode == .scaleAspectFill {
+            minScale = max(scaleX, scaleY)
+        } else if contentMode == .center {
+            if scaleX >= 1 && scaleY >= 1 {
+                minScale = 1
+            } else {
+                minScale = min(scaleX, scaleY)
+            }
+        }
+        return minScale
+    }
 
     /**
      *  重置图片或视频的大小，使用的场景例如：相册控件里放大当前图片、划到下一张、再回来，当前的图片或视频应该恢复到原来大小。

            return CGPoint(x: x, y: y)
        }()
    }

    public let emptyView = QMUIEmptyView()
    

        
        let enabledZoomImageView = self.enabledZoomImageView
        let minimumZoomScale = self.minimumZoomScale
        var maximumZoomScale = enabledZoomImageView ? self.maximumZoomScale : minimumZoomScale
        maximumZoomScale = max(minimumZoomScale, maximumZoomScale)// 可能外部通过 contentMode = UIViewContentModeScaleAspectFit 的方式来让小图片撑满当前的 zoomImageView，所以算出来 minimumZoomScale 会很大（至少比 maximumZoomScale 大），所以这里要做一个保护
        let zoomScale = minimumZoomScale
        let shouldFireDidZoomingManual = zoomScale == scrollView.zoomScale
        scrollView.panGestureRecognizer.isEnabled = enabledZoomImageView
        scrollView.pinchGestureRecognizer?.isEnabled = enabledZoomImageView
        scrollView.minimumZoomScale = minimumZoomScale
        scrollView.maximumZoomScale = maximumZoomScale
        setZoomScale(zoomScale, animated: false)
