Setting group image converts to JPEG with black background
- Operating System (Linux/Mac/Windows/iOS/Android): macOS
- Delta Chat Version: 1.29.0
- Expected behavior: Image maintains transparency or uses white background
- Actual behavior: Image loses transparency and/or uses black background
- Steps to reproduce the problem: Upload a group image
Below is a sample image that can be used for testing. Because it's only a line drawing it ends up being completely black.

Expected behavior: Image maintains transparency or uses white background
maintaining transparency should be done only as a workaround if it is the simpler solution "for now". transparency, shapes, alpha in user-avatars and webxdc-icons is a non-goal, resulting easily in lots of issues.
using a defined background color seems to be the better solution - and even if one could also have a png with only white lines, defaulting to a white background probably solves the majority of cases in practice.
defaulting to a white background probably solves the majority of cases in practice.
Yes I was basically suggesting this, as I have used images from the web several times for group discussions, and each time I need to convert it to jpeg in order for it to appear correctly. Seems like it would be simple to solve.
using a defined background color seems to be the better solution
There could be a user defined colour but the app converts the image to jpeg with a black background, so any CSS styling would be overlapped.
in desktop this is done by core, though on iOS the background is set to white instead of black, so maybe iOS has different logic for it?
while we should check if core actually recodes png to jpg and if we can set another background for transparency on that way, i would say that it still makes sense if the UI use "white" as a background as a last resort. or is this complex in case of desktop?
desktop just gives filename/path to core AFAIK, so nothing desktop can do in this case, right?
it could maybe set css-background to "white" similar as done recently for webxdc icons.
BTW: can not reproduce on desktop linux on 1.34 atleast on the device that sets it transparency stays
using the image from above in the desktop 1.34.0 on ubuntu results in different rendering of the image:
- white or transparent background in the edit dialog after selecting, black on reopening edit dialog
- black background in the chatlist and in the chat title

~~if the background is set to white everywhere, things are already fine. that seems to be an easier solution as doing things in core, esp. as i think, the fallback "white" or "unique" background is needed anyway.~~ EDIT: while checking the css, indeed, the avatar is a jpeg, so there is not much desktop can do here. we have to pass the desired background to thumbnail generation somehow.
so can reproduce too with the specific image rosano posted above, my own png with transparency remained transparent. maybe it has a flag set for background color or sth like that in the png metadata?
my theory why it works on ios: the relatively large png is recoded to a smaller png (preserving transparency) already by the ios crop util. because of "already small enough, core does nothing, and as white is used as bg color things are fine. in case of desktop core recodes to jpg with replacing transparency to black (instead of white).
Seems image crate encoder for JPEG accepts rgba images:
https://github.com/image-rs/image/blob/f1e34f365133a33a27dac5bc59c93d1cfb34a37e/src/codecs/jpeg/encoder.rs#L471-L475
But I have not figured out what it does in this case just from looking at the code.
Guess we just need recode_to_size to convert the image to rgb without alpha channel and white background first.
Related issue: https://github.com/image-rs/image/issues/2033