element-hq / element-x-ios

Next generation Matrix client for iOS built with SwiftUI on top of matrix-rust-sdk.
https://element.io/labs/element-x
GNU Affero General Public License v3.0
396 stars 88 forks source link

Element X should convert HEIC to JPG when posting #1946

Open ajkessel opened 10 months ago

ajkessel commented 10 months ago

Steps to reproduce

The Element iOS client converts HEIC to JPG when they are added to a room. This allows the images to be viewed properly on other clients, since Chromium doesn't support HEIC. When the same image is posted to a room on Element-X, it remains in HEIC format, so other users cannot view it without, e.g., saving and opening with Mac Safari or Preview. Can Element-X leverage the same iOS functionality (I assume built in to the OS) that Element uses to convert HEICs on upload?

Outcome

HEIC should be converted to JPG, but it's not.

Your phone model

No response

Operating system version

No response

Application version

No response

Homeserver

No response

Will you send logs?

No

marwing commented 10 months ago

Some additional context: This was discussed multiple times in #synapse:matrix.org and #element-x-ios:matrix.org (see here and here including the following conversations). iOS (and iPadOS) already converts images by default when picked using iOS' photo picker or shared using a share extension (macOS supposedly does not, but I haven't tested this). While Element X doesn't have a share extension yet (see #1477), it does use the photo picker and images get converted to jpeg by default (overridable by the user). ~iOS apparently does not convert images when copied and pasted into Element X.~

I would personally prefer if Element X did not unconditionally convert images (or any media for that matter), especially if iOS does it by default already. In some situations, I may explicitly want to send the original file without potential quality reductions, knowing the receiving side can handle it.

ajkessel commented 10 months ago

Maybe I misunderstand the current behavior. Based on a recent test, a locally-stored HEIC image posted via iOS Element came through in the room as JPEG, but the same image posted via iOS Element-X came through in the room as HEIC. It sounds like you understand the current behavior to be different?

marwing commented 10 months ago

I do. I just tested this again. Afaik, Element X itself doesn't convert the image, however, the iOS photo picker does by default. I also just tested copy/paste again, and iOS does convert from heif to jpeg when I copy from the Photos app. I verified this by looking at the event's json, as well as being able to view the image in element-web (which doesn't work for heif images). In both cases, you can tell iOS to not convert, but this requires explicit user action.

ajkessel commented 10 months ago

OK, this is very strange. I have multiple image postings from yesterday via Element-X where the file is definitely in the room as an HEIC (and thus not viewable in full form on other clients including desktop/web), but I just tried it again now and it did auto-convert. I can't think of what I might have been doing yesterday different from today, and I certainly haven't changed any software. Could there be some condition necessary for the conversion to occur?

ajkessel commented 10 months ago

Update: I think it's a timing issue. If I take a photo and immediately add it to a room, it shows up as a HEIC. If it's older, it shows up as a JPEG. Strange!

HealsCodes commented 8 months ago

I don't think it's timing, the SwiftUI image picker has 3 format choices and 'Automatic' does not mean JPG - maybe check what your selection is as well (note that this is unrelated to you generic Settings.app):

image

image

MuhannadYT commented 5 months ago

Having a send original option should fix this, as the user can select it if they want to send the original file or not

HealsCodes commented 5 months ago

Having a send original option should fix this, as the user can select it if they want to send the original file or not

It won't - the SwiftUI picker already has "Send Original" in it's options tab at the bottom - it's Called "Current" as you can see in my screenshot.

There is, however no way to force the picker to give you a JPEG and "Automatic" and well as "Most Compatible" both have no guarantee to return a JPEG and the Originals are stored as HEIC in the Camera Roll by default.