Merge pull request #319 from RyanRory/fix-thumbnail

Fix image attachment thumbnail generation
pull/1053/head
RyanZhao 6 months ago committed by GitHub
commit 83911cf9f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -7778,6 +7778,7 @@
CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 496;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -7815,6 +7816,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 2.8.2;
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
@ -7847,6 +7849,7 @@
CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 496;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -7884,6 +7887,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 2.8.2;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
PRODUCT_NAME = Session;

@ -104,7 +104,7 @@ public class ThumbnailService {
let thumbnailImage: UIImage
if attachment.isImage || attachment.isAnimated {
thumbnailImage = try MediaUtils.thumbnail(forImageAtPath: originalFilePath, maxDimension: maxDimension)
thumbnailImage = try MediaUtils.thumbnail(forImageAtPath: originalFilePath, maxDimension: maxDimension, type: attachment.contentType)
}
else if attachment.isVideo {
thumbnailImage = try MediaUtils.thumbnail(forVideoAtPath: originalFilePath, maxDimension: maxDimension)

@ -18,13 +18,13 @@ public enum MediaUtils {
public static let maxStillImageDimensions: UInt = 8 * 1024
public static let maxVideoDimensions: CGFloat = 3 * 1024
public static func thumbnail(forImageAtPath path: String, maxDimension: CGFloat) throws -> UIImage {
public static func thumbnail(forImageAtPath path: String, maxDimension: CGFloat, type: String) throws -> UIImage {
SNLog("thumbnailing image: \(path)")
guard FileManager.default.fileExists(atPath: path) else {
throw MediaError.failure(description: "Media file missing.")
}
guard Data.isValidImage(at: path) else {
guard Data.isValidImage(at: path, type: UTType(sessionMimeType: type)) else {
throw MediaError.failure(description: "Invalid image.")
}
guard let originalImage = UIImage(contentsOfFile: path) else {

Loading…
Cancel
Save