Skip to content

Commit

Permalink
Version 1.0.3.15259
Browse files Browse the repository at this point in the history
- Added thumbnail imageQuality attribute which can be setted on the ROThumbnail class
- Fixed bug if Capital file extensions (thanks to JanBorowskiES)
  • Loading branch information
Robin Oster committed Sep 16, 2015
1 parent ba6fb8f commit a9de6a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ROThumbnailGenerator.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions ROThumbnailGenerator/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>15224</string>
<string>15259</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
13 changes: 10 additions & 3 deletions Source/ROThumbnail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, ROThumbnailGenerator> = [:]

init() {
Expand All @@ -34,7 +35,7 @@ public class ROThumbnail {
*/
public func addThumbnailGenerator(thumbnailGenerator:ROThumbnailGenerator) {
for fileExtension in thumbnailGenerator.supportedExtensions {
supportedFiletypes[fileExtension] = thumbnailGenerator
supportedFiletypes[fileExtension.lowercaseString] = thumbnailGenerator
}
}

Expand All @@ -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")!
Expand Down

0 comments on commit a9de6a8

Please sign in to comment.