Add more path to compressor image

This commit is contained in:
Thomas Ricouard 2023-03-11 13:42:07 +01:00
parent f172d6d4a6
commit 0132e51509
2 changed files with 3 additions and 3 deletions

View file

@ -35,7 +35,6 @@ actor StatusEditorCompressor {
let isPNG: Bool = { let isPNG: Bool = {
guard let utType = cgImage.utType else { return false } guard let utType = cgImage.utType else { return false }
return (utType as String) == UTType.png.identifier return (utType as String) == UTType.png.identifier
}() }()
let destinationProperties = [ let destinationProperties = [

View file

@ -68,13 +68,14 @@ enum StatusEditorUTTypeSupported: String, CaseIterable {
} else if let transferable = await getImageTansferable(item: item) { } else if let transferable = await getImageTansferable(item: item) {
return transferable return transferable
} }
let compressor = StatusEditorCompressor()
let result = try await item.loadItem(forTypeIdentifier: rawValue) let result = try await item.loadItem(forTypeIdentifier: rawValue)
if self == .jpeg || self == .png || self == .tiff || self == .image || self == .uiimage || self == .adobeRawImage { if self == .jpeg || self == .png || self == .tiff || self == .image || self == .uiimage || self == .adobeRawImage {
if let image = result as? UIImage { if let image = result as? UIImage {
return image return image
} else if let imageURL = result as? URL, } else if let imageURL = result as? URL,
let data = try? Data(contentsOf: imageURL), let compressedData = await compressor.compressImageFrom(url: imageURL),
let image = UIImage(data: data) let image = UIImage(data: compressedData)
{ {
return image return image
} else if let data = result as? Data, } else if let data = result as? Data,