         // Crop out any part of the image that's larger than the thumbnail size
         // The cropped rect must be centered on the resized image
         // Round the origin points so that the size isn't altered when CGRectIntegral is later invoked
-        let croppedRect = CGRect(x: ((resizedImage.scaledWidth - sizet) * 0.5).rounded(), y: ((resizedImage.scaledHeight - sizet) * 0.5).rounded(), width: sizet, height: sizet)
+        let croppedRect = CGRect(x: ((resizedImage.size.width - sizet) * 0.5).rounded(), y: ((resizedImage.size.width - sizet) * 0.5).rounded(), width: sizet, height: sizet)
         guard let croppedImage = resizedImage.crop(to: croppedRect) else { return nil }
         var borderedImage = croppedImage
         if borderWidth > 0.0 { borderedImage = croppedImage.bordered(borderWidth) }
         
         return borderedImage.round(cornerRadius, border: borderWidth)
     }
-    /// Creates a copy of this image that is scale-aspect-fit to the thumbnail size using `ImageIO`.
+    /// Creates a copy of this image that is scale-aspect-fit to the thumbnail size using `ImageIO` in points.
     /// Animated image supported.
     ///
     /// - Parameter size: A size of thumbnail to scale-aspect-fit to.

        
        var resultImage: UIImage = self
        images.forEach { (image) in autoreleasepool{
            var resultRect = CGRect(origin: .zero, size: resultImage.scaledSize)
            var pageRect   = CGRect(origin: .zero, size: image.scaledSize)
            var imageRect  : CGRect = .zero
            switch mode {
            case .overlay(let resizing):

    /// If the new size is not integral, it will be rounded up.
    private func _resize(fills newSize: CGSize, applying transform: CGAffineTransform, transposed: Bool, quality: CGInterpolationQuality) -> UIImage! {
        guard !animatable else { return UIImage.animatedImage(with: self.images!.flatMap({ _img in autoreleasepool{ _img._resize(fills: newSize, applying: transform, transposed: transposed, quality: quality) } }), duration: duration) }
        // Scales points to pxiels.
        let newRect        = CGRect(origin: .zero, size: newSize).integral.scale(by: scale)
        let transposedRect = CGRect(origin: .zero, size: CGSize(width: newRect.height, height: newRect.width)).integral.scale(by: scale)
        guard let cgImage = self.cgImage, let colorSpace = cgImage.colorSpace else { return nil }
        // Build a context that's the same dimensions as the new size
        // FIXME: How to decide the right alpha info of the bitmap.
