Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a33c0e4a
authored
Sep 09, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正压缩图片逻辑
parent
634a14d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
MRFramework/MRFramework/Extensions/UIKit/UIImage+file.swift
+7
-9
No files found.
MRFramework/MRFramework/Extensions/UIKit/UIImage+file.swift
View file @
a33c0e4a
...
...
@@ -13,9 +13,9 @@ import Photos
public
typealias
UIImageSaveToAlbumCompleteBlock
=
(
_
image
:
UIImage
,
_
saveURL
:
URL
?,
_
error
:
Error
?)
->
Void
extension
UIImage
{
public
enum
SaveConfig
{
public
enum
SaveConfig
:
Equatable
{
case
`
default
`
case
custom
(
_
thumbSize
:
CGSize
?
,
_
quality
:
CGFloat
)
case
custom
(
_
thumbSize
:
CGSize
,
_
quality
:
CGFloat
)
}
}
...
...
@@ -49,7 +49,7 @@ extension UIImage {
switch
config
{
case
.
custom
(
let
size
,
let
quality
):
q
=
quality
if
let
size
=
size
,
let
thumbImage
=
self
.
thumbImage
(
size
)
{
if
let
thumbImage
=
self
.
thumbImage
(
size
)
{
thumbPath
=
url
.
appendingPathComponent
(
self
.
thumbName
(
with
:
name
,
size
:
thumbImage
.
size
))
let
error
=
thumbImage
.
writeFile
(
to
:
thumbPath
!
,
q
)
if
error
!=
nil
{
...
...
@@ -65,14 +65,12 @@ extension UIImage {
}
let
fullPath
=
url
.
appendingPathComponent
(
name
)
do
{
try
self
.
jpegData
(
compressionQuality
:
q
)?
.
write
(
to
:
fullPath
)
DispatchQueue
.
main
.
async
{
complate
?(
fullPath
,
thumbPath
,
nil
)
}
}
catch
let
error
{
let
error
=
self
.
writeFile
(
to
:
fullPath
,
q
)
DispatchQueue
.
main
.
async
{
if
let
error
=
error
{
complate
?(
nil
,
nil
,
error
)
}
else
{
complate
?(
fullPath
,
thumbPath
,
nil
)
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment