parent
6ef643e374
commit
b2956b6118
|
@ -493,10 +493,20 @@ class ComposeViewController: UIViewController {
|
||||||
options.resizeMode = .none
|
options.resizeMode = .none
|
||||||
options.isNetworkAccessAllowed = true
|
options.isNetworkAccessAllowed = true
|
||||||
PHImageManager.default().requestImageDataAndOrientation(for: asset, options: options) { (data, dataUTI, orientation, info) in
|
PHImageManager.default().requestImageDataAndOrientation(for: asset, options: options) { (data, dataUTI, orientation, info) in
|
||||||
guard let data = data, let dataUTI = dataUTI else { fatalError() }
|
guard var data = data, let dataUTI = dataUTI else { fatalError() }
|
||||||
|
|
||||||
let mimeType = UTTypeCopyPreferredTagWithClass(dataUTI as CFString, kUTTagClassMIMEType)!.takeRetainedValue() as String
|
|
||||||
|
|
||||||
|
let mimeType: String
|
||||||
|
if dataUTI == "public.heic" {
|
||||||
|
// neither Mastodon nor Pleroma handles HEIC well, so convert to JPEG
|
||||||
|
let image = CIImage(data: data)!
|
||||||
|
let context = CIContext()
|
||||||
|
let colorSpace = image.colorSpace ?? CGColorSpace(name: CGColorSpace.sRGB)!
|
||||||
|
data = context.jpegRepresentation(of: image, colorSpace: colorSpace, options: [:])!
|
||||||
|
mimeType = "image/jpeg"
|
||||||
|
} else {
|
||||||
|
mimeType = UTTypeCopyPreferredTagWithClass(dataUTI as CFString, kUTTagClassMIMEType)!.takeRetainedValue() as String
|
||||||
|
}
|
||||||
|
|
||||||
self.postProgressView.step()
|
self.postProgressView.step()
|
||||||
|
|
||||||
let request = MastodonController.client.upload(attachment: FormAttachment(mimeType: mimeType, data: data, fileName: "file"), description: description)
|
let request = MastodonController.client.upload(attachment: FormAttachment(mimeType: mimeType, data: data, fileName: "file"), description: description)
|
||||||
|
|
Loading…
Reference in New Issue