Skip to content

Commit a9de6a8

Browse files
author
Robin Oster
committed
Version 1.0.3.15259
- Added thumbnail imageQuality attribute which can be setted on the ROThumbnail class - Fixed bug if Capital file extensions (thanks to JanBorowskiES)
1 parent ba6fb8f commit a9de6a8

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

ROThumbnailGenerator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Pod::Spec.new do |s|
1111
s.name = "ROThumbnailGenerator"
12-
s.version = "1.0.2"
12+
s.version = "1.0.3"
1313
s.summary = "Creates thumbnails of different file types very easily"
1414
s.description = <<-DESC
1515
It does create a thumbnail by the given file url. Creation of PDF, Image and Video thumbnails is per default supported.

ROThumbnailGenerator/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.2</string>
18+
<string>1.0.3</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>15224</string>
22+
<string>15259</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UILaunchStoryboardName</key>

Source/ROThumbnail.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import UIKit
1111
public class ROThumbnail {
1212

1313
public static let sharedInstance:ROThumbnail = ROThumbnail()
14+
public var imageQuality:CGFloat = 1.0 // Default is 100% JPEG image quality
1415
private var supportedFiletypes:Dictionary<String, ROThumbnailGenerator> = [:]
1516

1617
init() {
@@ -34,7 +35,7 @@ public class ROThumbnail {
3435
*/
3536
public func addThumbnailGenerator(thumbnailGenerator:ROThumbnailGenerator) {
3637
for fileExtension in thumbnailGenerator.supportedExtensions {
37-
supportedFiletypes[fileExtension] = thumbnailGenerator
38+
supportedFiletypes[fileExtension.lowercaseString] = thumbnailGenerator
3839
}
3940
}
4041

@@ -46,8 +47,14 @@ public class ROThumbnail {
4647
*/
4748
public func getThumbnail(url:NSURL) -> UIImage {
4849
if let fileExtension = url.pathExtension {
49-
var appropriateThumbnailGenerator = supportedFiletypes[fileExtension] ?? DefaultThumbnailGenerator()
50-
return appropriateThumbnailGenerator.getThumbnail(url)
50+
var appropriateThumbnailGenerator = supportedFiletypes[fileExtension.lowercaseString] ?? DefaultThumbnailGenerator()
51+
var thumbnail = appropriateThumbnailGenerator.getThumbnail(url)
52+
53+
// Image quality of the thumbnail is defined in the imageQuality variable, can be setted from outside
54+
var jpeg:NSData = UIImageJPEGRepresentation(thumbnail, imageQuality)
55+
thumbnail = UIImage(data: jpeg)!
56+
57+
return thumbnail
5158
}
5259

5360
return UIImage(named:"fallbackIcon")!

0 commit comments

Comments
 (0)