mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
75607c73ec
* Resolve the real image format before choosing the encoder The upload pre-processor picks the encoder from the mime type it is given. When an image is shared from another app that type is often broader than the image really is, so a transparent PNG shared as a wildcard image type is re-encoded as JPEG and its alpha channel is flattened to black. Read the format from the image header when the declared type is not already a concrete PNG or JPEG, and use that to decide both whether the image can be compressed at all and which encoder to use. * Cover the mime type fallbacks the wildcard resolution introduced resolveImageMimeType now decides whether an image is compressible, so two of its outcomes had no test: a GIF shared with a wildcard type has to be recognised and left uncompressed rather than recompressed into a still, and a file the decoder cannot read at all has to fall back to the type it was shared with. The isMimeTypeImage() guard on the decoded type is dropped with them. The BitmapFactory decoders only ever report an image type in outMimeType, so the guard could not fire and there was no way to exercise it.