// // ProcessThumbnal.swift // ProcessCheckFile // // Created by 朱东勇 on 2022/12/9. // import Foundation import QuickLook import QuickLookUI import QuickLookThumbnailing let generator = QLThumbnailGenerator.shared class ProcessThumbnal : NSObject { class func process(_ filePath:String) { let url = URL.init(filePath: filePath) generator.generateRepresentations(for: QLThumbnailGenerator.Request.init(fileAt: url, size: CGSizeMake(1024.0, 10240.0), scale: 1.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail), update: { (representation, type, error) in let image = representation!.nsImage as NSImage try? image.tiffRepresentation?.write(to: URL.init(filePath: "/Users/zhudongyong/Desktop/imae01.png")) NSLog("\(representation?.nsImage)\(error)") }) generator.generateRepresentations(for: QLThumbnailGenerator.Request.init(fileAt: url, size: CGSizeMake(1024.0, 10240.0), scale: 1.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail), update: { (representation, type, error) in let image = representation!.nsImage as NSImage try? image.tiffRepresentation?.write(to: URL.init(filePath: "/Users/zhudongyong/Desktop/imae02.png")) NSLog("\(representation?.nsImage)\(error)") }) // return [] } }