mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
platform thumbhash
This commit is contained in:
parent
84462560e3
commit
c988342de1
15 changed files with 581 additions and 44 deletions
|
|
@ -47,6 +47,16 @@ class ThumbnailApiImpl: ThumbnailApi {
|
|||
return assetCache
|
||||
}()
|
||||
|
||||
func getThumbhash(thumbhash: String, completion: @escaping (Result<[String : Int64], any Error>) -> Void) {
|
||||
Self.processingQueue.async {
|
||||
guard let data = Data(base64Encoded: thumbhash)
|
||||
else { return completion(.failure(PigeonError(code: "", message: "Invalid base64 string: \(thumbhash)", details: nil)))}
|
||||
|
||||
let (width, height, pointer) = thumbHashToRGBA(hash: data)
|
||||
completion(.success(["pointer": Int64(Int(bitPattern: pointer.baseAddress)), "width": Int64(width), "height": Int64(height)]))
|
||||
}
|
||||
}
|
||||
|
||||
func requestImage(assetId: String, requestId: Int64, width: Int64, height: Int64, completion: @escaping (Result<[String: Int64], any Error>) -> Void) {
|
||||
let request = Request(callback: completion)
|
||||
let item = DispatchWorkItem {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue