Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert photo images to JPEG (or WEBP) on image paste #15977

Closed
Pwuts opened this issue Dec 15, 2020 · 8 comments
Closed

Convert photo images to JPEG (or WEBP) on image paste #15977

Pwuts opened this issue Dec 15, 2020 · 8 comments

Comments

@Pwuts
Copy link

Pwuts commented Dec 15, 2020

Is your feature request related to a problem? Please describe.
When pasting a photo, it is always uploaded as a PNG, which uses up a lot of bandwidth and is suboptimal for photo type images.

Describe the solution you'd like
Either convert everything to WEBP, which is suitable for illustrations as well as photos, or try converting the pasted (PNG) image to JPG, and use that if it turns out (significantly) smaller.

@t3chguy
Copy link
Member

t3chguy commented Dec 15, 2020

That's not up to Element but your browser. Try pasting an image into http://madebyevan.com/clipboard-test/ regardless of whether it was originally a JPG or PNG the clipboard your browser exposes only contains a PNG.

@Pwuts
Copy link
Author

Pwuts commented Dec 19, 2020

Ah, TIL. :)

Nevertheless, it might still be worth it to do some conversion, as it can really save a LOT of bandwidth. I've seen examples of PNG pastes being 10x the size of the same file saved as JPG, with good quality settings.

@Pwuts Pwuts changed the title Decide between PNG and JPEG (or use WEBP) on image paste) Convert photo images to JPEG (or WEBP) on image paste Dec 19, 2020
@jryans jryans added the A-Media label Dec 22, 2020
@t3chguy
Copy link
Member

t3chguy commented Dec 29, 2020

I think this is better served by #14047 - rather than converting to a fixed format, giving the option to compress to different sizes is better. No one likes how hi-res images sent by WhatsApp/Facebook/Instagram turn out.

@t3chguy t3chguy closed this as completed Dec 29, 2020
@Pwuts
Copy link
Author

Pwuts commented Dec 29, 2020

No one likes how hi-res images sent by WhatsApp/Facebook/Instagram turn out

I think this comparison is out of place here. WhatsApp converts everything to small-size JPG which sucks for hi-res images or illustrations. I'm not sure about Facebook and Instagram but they don't handle things the same as WhatsApp does. As said, WEBP is suitable for both photo-type images and illustrations, and achieves good quality with respect to compressed size for both.

I feel like my suggestion hasn't been received correctly. I'm not advocating to "convert everything to a fixed format". I'm merely suggesting to convert images to a different format if that seems beneficial. The example I gave is photo type images being sent as huge PNGs, while they could be a lot smaller, (almost) without loss of quality, as either JPG(2000) or WEBP. Whether this is beneficial for an image can be determined by converting the large PNG buffer to either of those formats, and comparing the resulting buffer's size. If the converted format is more suitable, the converted result should be significantly smaller.

Also, as far as I can understand, #14047 actually suggests to compress everything sent through the client, which I think will cause more quality loss in more cases (which you are arguing is bad, and I agree).

@t3chguy
Copy link
Member

t3chguy commented Dec 29, 2020

Whether this is beneficial for an image can be determined by converting the large PNG buffer to either of those formats, and comparing the resulting buffer's size. If the converted format is more suitable, the converted result should be significantly smaller.

Doing this without the user's explicit intent is not user-friendly, #14047 gives that control to the user.
If a user is sending a PNG for some special reason, their file shouldn't arrive as a JPEG, they shouldn't be forced to have to zip it up.

#14047 says

It would be nice if there would be a message which let you choose to recompress the video at different quality levels (with a hint how large they will be) and also without recompression.

@Pwuts
Copy link
Author

Pwuts commented Dec 29, 2020

Doing this without the user's explicit intent is not user-friendly, #14047 gives that control to the user.
If a user is sending a PNG for some special reason, their file shouldn't arrive as a JPEG, they shouldn't be forced to have to zip it up.

I agree; hence my suggestion specifically pertains to pasted image content, not uploaded files.

#14047 says

It would be nice if there would be a message which let you choose to recompress the video at different quality levels (with a hint how large they will be) and also without recompression.

Ah, I missed that part, that's better indeed.

@t3chguy
Copy link
Member

t3chguy commented Dec 29, 2020

I agree; hence my suggestion specifically pertains to pasted image content, not uploaded files.

Right, but there's no way to know if you are copying from a browser which mangled your jpeg into png or from another application which you explicitly wanted to copy a png from

@Pwuts
Copy link
Author

Pwuts commented Dec 29, 2020

That argument is valid the other way around as well; there's no way to know whether the user explicitly wanted to copy something as a PNG (doesn't happen very much I imagine), or just copied an image which was pasted as a PNG because of browser stuff, while it wasn't actually a PNG (I'd say 50% of cases). There is no automated way to know, since everything is pasted as PNG.

Pasting or dropping files is distinguishable from pasting image content though, trusting the tool you shared in your first comment. In my case, pasting files doesn't even return anything.

Related to #14047: Extending the paste dialog with a form to choose the compression format and size/quality would solve edge cases where the user explicitly wants to send non-optimally compressed PNG content. It should, however, default to the format most optimal (size-wise) for sending the pasted content. For the majority of users, I think this would be fine; preferable even. It will reduce the amount of clicks needed for sending optimally sized images, reduce the amount of bandwidth needed to send and receive the content, and reduce the amount of disk space the system administrator needs for hosting a matrix server. With respect to bandwidth requirements, it is also an accessibility improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants