diff --git a/ROThumbnailGenerator.podspec b/ROThumbnailGenerator.podspec index 228e835..3ec8a7c 100644 --- a/ROThumbnailGenerator.podspec +++ b/ROThumbnailGenerator.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.name = "ROThumbnailGenerator" -s.version = "1.0.2" +s.version = "1.0.3" s.summary = "Creates thumbnails of different file types very easily" s.description = <<-DESC It does create a thumbnail by the given file url. Creation of PDF, Image and Video thumbnails is per default supported. diff --git a/ROThumbnailGenerator/Info.plist b/ROThumbnailGenerator/Info.plist index 2da58cf..99b270e 100644 --- a/ROThumbnailGenerator/Info.plist +++ b/ROThumbnailGenerator/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.2 + 1.0.3 CFBundleSignature ???? CFBundleVersion - 15224 + 15259 LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/Source/ROThumbnail.swift b/Source/ROThumbnail.swift index b18b3d8..1dcacf4 100644 --- a/Source/ROThumbnail.swift +++ b/Source/ROThumbnail.swift @@ -11,6 +11,7 @@ import UIKit public class ROThumbnail { public static let sharedInstance:ROThumbnail = ROThumbnail() + public var imageQuality:CGFloat = 1.0 // Default is 100% JPEG image quality private var supportedFiletypes:Dictionary = [:] init() { @@ -34,7 +35,7 @@ public class ROThumbnail { */ public func addThumbnailGenerator(thumbnailGenerator:ROThumbnailGenerator) { for fileExtension in thumbnailGenerator.supportedExtensions { - supportedFiletypes[fileExtension] = thumbnailGenerator + supportedFiletypes[fileExtension.lowercaseString] = thumbnailGenerator } } @@ -46,8 +47,14 @@ public class ROThumbnail { */ public func getThumbnail(url:NSURL) -> UIImage { if let fileExtension = url.pathExtension { - var appropriateThumbnailGenerator = supportedFiletypes[fileExtension] ?? DefaultThumbnailGenerator() - return appropriateThumbnailGenerator.getThumbnail(url) + var appropriateThumbnailGenerator = supportedFiletypes[fileExtension.lowercaseString] ?? DefaultThumbnailGenerator() + var thumbnail = appropriateThumbnailGenerator.getThumbnail(url) + + // Image quality of the thumbnail is defined in the imageQuality variable, can be setted from outside + var jpeg:NSData = UIImageJPEGRepresentation(thumbnail, imageQuality) + thumbnail = UIImage(data: jpeg)! + + return thumbnail } return UIImage(named:"fallbackIcon")!