-
-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
416 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// BaseUploaderUtil.swift | ||
// uPic | ||
// | ||
// Created by Svend Jin on 2019/8/8. | ||
// Copyright © 2019 Svend Jin. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class BaseUploaderUtil { | ||
static func compressImage(_ data: Data) -> Data { | ||
var factor:Int = ConfigManager.shared.compressFactor | ||
|
||
if factor >= 100 { | ||
return data | ||
} | ||
|
||
// 压缩图片 | ||
debugPrint("origin data -> \(data.bytes.count)") | ||
let retData = data.compressImage(Float(factor) / 100) | ||
debugPrint("compress data -> \(retData.bytes.count)") | ||
return retData | ||
} | ||
|
||
static func compressImage(_ url: URL) -> Data? { | ||
var factor:Int = ConfigManager.shared.compressFactor | ||
|
||
if factor >= 100 { | ||
return nil | ||
} | ||
|
||
let data = try? Data(contentsOf: url) | ||
// 压缩图片 | ||
debugPrint("origin data -> \(data?.bytes.count)") | ||
let retData = data?.compressImage(Float(factor) / 100) | ||
debugPrint("compress data -> \(retData?.bytes.count)") | ||
return retData | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.