         var frame = CGRect.zero
         frame.origin = CGPoint.zero
         
-        let height = image.size.height * (self.bounds.width / image.size.width)
-        let width = image.size.width * (self.bounds.height / image.size.height)
+        let height = image.size.height * (bounds.width / image.size.width)
+        let width = image.size.width * (bounds.height / image.size.height)
         
         if image.size.width > image.size.height {
             
-            frame.size = CGSize(width: self.bounds.width, height: height)
-            if height >= self.bounds.height {
-                frame.size = CGSize(width: width, height: self.bounds.height)
+            frame.size = CGSize(width: bounds.width, height: height)
+            if height >= bounds.height {
+                frame.size = CGSize(width: width, height: bounds.height)
             }
             
         } else {
 
-            frame.size = CGSize(width: width, height: self.bounds.height)
-            if width >= self.bounds.width {
-                frame.size = CGSize(width: self.bounds.width, height: height)
+            frame.size = CGSize(width: width, height: bounds.height)
+            if width >= bounds.width {
+                frame.size = CGSize(width: bounds.width, height: height)
             }
 
         }

        let constraints = [
            progressView.heightAnchor.constraint(equalToConstant: 40.0),
            progressView.widthAnchor.constraint(equalToConstant: 40.0),
            progressView.centerXAnchor.constraint(lessThanOrEqualTo: self.centerXAnchor, constant: 1.0),
            progressView.centerYAnchor.constraint(lessThanOrEqualTo: self.centerYAnchor, constant: 1.0),
            ].map { $0.isActive = true }
     }
    

extension ImageView {

    func didDoubleTap(_ sender: UIGestureRecognizer) {
        if scrollView.zoomScale == 1.0 {
            let touchPoint = sender.location(in: self)
            scrollView.zoom(to: CGRect(x: touchPoint.x, y: touchPoint.y, width: 1, height: 1), animated: true)
        } else {
