Commit 124fdd8b authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Kateryna Kostiuk

fix: change image to png for non-jpg images, use filename to send

Change-Id: I3a92804aefdaea779a785c36c81f1a8abd99c845
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 2501d6c6
......@@ -126,11 +126,9 @@ class ConversationViewController: UIViewController, UITextFieldDelegate,
func copyImageToCache(image: UIImage, imagePath: String) {
guard let imageData = UIImagePNGRepresentation(image) else { return }
// set the extension to png
let copiedImagePath = (imagePath as NSString).deletingPathExtension + ".png"
do {
self.log.debug("copying image to: \(String(describing: copiedImagePath))")
try imageData.write(to: URL(fileURLWithPath: copiedImagePath), options: .atomic)
self.log.debug("copying image to: \(String(describing: imagePath))")
try imageData.write(to: URL(fileURLWithPath: imagePath), options: .atomic)
} catch {
self.log.error("couldn't copy image to cache")
}
......@@ -162,8 +160,9 @@ class ConversationViewController: UIViewController, UITextFieldDelegate,
let result = PHAsset.fetchAssets(withALAssetURLs: [imageURL], options: nil)
var imageFileName = result.firstObject?.value(forKey: "filename") as? String ?? "Unknown"
// set the extension to png if not a jpg
let pathExtension = (imageFileName as NSString).pathExtension
if pathExtension == "HEIC" || pathExtension == "HEIF" {
if pathExtension != "jpg" || pathExtension == "JPG" {
imageFileName = (imageFileName as NSString).deletingPathExtension + ".png"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment