Skip to content

Commit

Permalink
Change ROThumbnail.swift to safely compress images into JPEGs
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrisdf authored Aug 29, 2017
1 parent 7660544 commit 2d3b118
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Source/ROThumbnail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ open class ROThumbnail {
// Don't perform compression if image quality is set to 100%
if imageQuality < 1 {
// Image quality of the thumbnail is defined in the imageQuality variable, can be setted from outside
let jpeg:Data = UIImageJPEGRepresentation(thumbnail, imageQuality)!
thumbnail = UIImage(data: jpeg)!
if let jpeg = UIImageJPEGRepresentation(thumbnail, imageQuality) {
if let compressedImage = UIImage(data: jpeg) {
thumbnail = compressedImage
}
}
}


Expand Down

0 comments on commit 2d3b118

Please sign in to comment.