Skip to content

Commit

Permalink
Merge pull request #180 from zhusongyu/master
Browse files Browse the repository at this point in the history
修复图片压缩算法,防止 proportion 为 1 时进入死循环
  • Loading branch information
nixzhu authored Sep 24, 2020
2 parents a6fae66 + a390815 commit f1a2524
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/MonkeyKing/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ extension UIImage {

if imageData == nil {
let currentMiniIamgeDataSize = jpegData(compressionQuality: 0.01)?.count ?? 0
let proportion = CGFloat(currentMiniIamgeDataSize / maxSize)
var proportion = CGFloat(currentMiniIamgeDataSize / maxSize)
proportion = proportion == 1 ? 2 : proportion
let newWidth = image.size.width * scale / proportion
let newHeight = image.size.height * scale / proportion
let newSize = CGSize(width: newWidth, height: newHeight)
Expand Down

0 comments on commit f1a2524

Please sign in to comment.