diff --git a/Palace.xcodeproj/project.pbxproj b/Palace.xcodeproj/project.pbxproj index 30c332ba8..743c62428 100644 --- a/Palace.xcodeproj/project.pbxproj +++ b/Palace.xcodeproj/project.pbxproj @@ -4732,6 +4732,8 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 389; + CURRENT_PROJECT_VERSION = 390; + CURRENT_PROJECT_VERSION = 391; DEVELOPMENT_TEAM = 88CBA74T8K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K; ENABLE_BITCODE = NO; @@ -4753,7 +4755,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.0.0; + MARKETING_VERSION = 2.0.1; PRODUCT_BUNDLE_IDENTIFIER = org.thepalaceproject.palace; PRODUCT_MODULE_NAME = Palace; PRODUCT_NAME = "Palace-noDRM"; @@ -4791,6 +4793,8 @@ CODE_SIGN_ENTITLEMENTS = Palace/SimplyE.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CURRENT_PROJECT_VERSION = 389; + CURRENT_PROJECT_VERSION = 390; + CURRENT_PROJECT_VERSION = 391; DEVELOPMENT_TEAM = 88CBA74T8K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K; ENABLE_BITCODE = NO; @@ -4812,7 +4816,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.0.0; + MARKETING_VERSION = 2.0.1; PRODUCT_BUNDLE_IDENTIFIER = org.thepalaceproject.palace; PRODUCT_MODULE_NAME = Palace; PRODUCT_NAME = "Palace-noDRM"; @@ -4975,6 +4979,8 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 389; + CURRENT_PROJECT_VERSION = 390; + CURRENT_PROJECT_VERSION = 391; DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -5036,6 +5042,8 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 389; + CURRENT_PROJECT_VERSION = 390; + CURRENT_PROJECT_VERSION = 391; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K; ENABLE_BITCODE = NO; diff --git a/Palace/Book/Models/TPPBook.swift b/Palace/Book/Models/TPPBook.swift index 5aa9bbd6b..33865e13b 100644 --- a/Palace/Book/Models/TPPBook.swift +++ b/Palace/Book/Models/TPPBook.swift @@ -600,22 +600,44 @@ private extension TPPBook { DispatchQueue.global(qos: .userInitiated).async { [weak self] in guard let self = self else { return } - let ciImage = CIImage(image: inputImage) + guard let ciImage = CIImage(image: inputImage) else { + Log.debug(#file, "Failed to create CIImage from UIImage for book: \(self.identifier)") + return + } + + guard !ciImage.extent.isEmpty else { + Log.debug(#file, "CIImage has empty extent for book: \(self.identifier)") + return + } + let filter = CIFilter.areaAverage() filter.inputImage = ciImage - filter.extent = ciImage?.extent ?? .zero + filter.extent = ciImage.extent - guard let outputImage = filter.outputImage else { return } + guard let outputImage = filter.outputImage else { + Log.debug(#file, "Failed to generate output image from filter for book: \(self.identifier)") + return + } + + guard let colorSpace = CGColorSpace(name: CGColorSpace.sRGB) else { + Log.debug(#file, "Failed to create sRGB color space for book: \(self.identifier)") + return + } var bitmap = [UInt8](repeating: 0, count: 4) - let context = CIContext(options: [CIContextOption.useSoftwareRenderer: false]) + let context = CIContext(options: [ + .workingColorSpace: colorSpace, + .outputColorSpace: colorSpace, + .useSoftwareRenderer: false + ]) + context.render( outputImage, toBitmap: &bitmap, rowBytes: 4, bounds: CGRect(x: 0, y: 0, width: 1, height: 1), format: .RGBA8, - colorSpace: nil + colorSpace: colorSpace ) let color = UIColor(