Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
# Upcoming

### 🔄 Changed
- Uploading a HEIC photo from the library is now converted to JPEG for better compatibility [#767](https://github.com/GetStream/stream-chat-swiftui/pull/767)

# [4.73.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.73.0)
_February 28, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public struct PhotoAttachmentCell: View {
.allowsHitTesting(true)
.onTapGesture {
withAnimation {
if let assetURL = assetURL {
if let assetURL = assetJpgURL() {
onImageTap(
AddedAsset(
image: image,
Expand Down Expand Up @@ -193,4 +193,13 @@ public struct PhotoAttachmentCell: View {
}
}
}

/// The original photo is usually in HEIC format.
/// This makes sure that the photo is converted to JPG.
/// This way it is more compatible with other platforms.
private func assetJpgURL() -> URL? {
guard let assetURL = assetURL else { return nil }
guard let assetData = try? Data(contentsOf: assetURL) else { return nil }
return try? UIImage(data: assetData)?.temporaryLocalFileUrl()
Copy link
Contributor

@laevandus laevandus Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but I did not know that temporaryLocalFileUrl actually goes and converts the image to JPEG. We should probably rename this at some point.

I guess this is fast enough that we don't need any async call for this.

Copy link
Member Author

@nuno-vieira nuno-vieira Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I actually changed it and then reverted it. But I think we can do it already here. It makes sense to rename it on UIKit as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fast enough that we don't need any async call for this.

Yes it is quite fast, and is also only executed when an attachment is added to the composer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅ Let me know WDYT

}
}
Loading