aaronpk / webmention.io

Easily enable webmentions on any web site
https://webmention.io/
Other
775 stars 38 forks source link

Webmention avatars are sometimes very large #126

Closed zachleat closed 1 year ago

zachleat commented 5 years ago

Is there anything we can do to make these smaller?

One example: https://s3-us-west-2.amazonaws.com/ca3db/pbs.twimg.com/c6a1f32b02f28ef98c38ea471a1a6187b64395d03db93947ee28165e66a8fc38.png

256x256, 135KB 😱

Another, 256x256 84.4KB: https://s3-us-west-2.amazonaws.com/ca3db/pbs.twimg.com/2cb539703b09adb2ef4818c0fa52e2d97c6b8365befe25ba741bbc98ca12fde9.png

How are these fetched?

It looks like the Twitter API supports standardized sizes https://developer.twitter.com/en/docs/accounts-and-users/user-profile-images-and-banners.html

aaronpk commented 5 years ago

256px is the smaller resized version. webmention.io will resize all avatars down to 256px regardless of whether they come from Twitter accounts or individual blogs.

The avatars don't always come from Twitter so I can't rely on using the twitter API for fetching profile images.

zachleat commented 5 years ago

A ha—cruised through the source a bit and found https://github.com/aaronpk/ca3db-ruby

I wonder if it’s possible to entertain reducing this max size? Is this a change you might be comfortable with? Or a query param to opt-in to save some bandwidth?

Your site renders these at 36×36 (which would need a 7× retina screen to see 256×256 level of detail, but I believe that’s well beyond what the human eye is capable of—not counting for page zoom, of course)

aaronpk commented 5 years ago

yeah I show them kinda small, but some people show them a lot bigger.

One trick here is that the resizing is done system-wide, not per user account. So I can't make it resize avatars for you differently than for other users of webmention.io. The only way around that would be to let you put in your own S3 credentials to save the resized avatars to your own S3 account, and then I could let you also choose the dimensions. Is that something you'd be interested in?

There is already a checkbox in the settings where you can opt out of the resizing/archiving entirely, for example if you wanted to handle resizing on your own.

zachleat commented 5 years ago

Yeah that would be great! Just as info this request is not high priority.

nhoizey commented 2 years ago

Would it make sense for webmention.io to provide 1 or 2 smaller dimensions, for example 128×128 and 64×64, which would be much lighter?

Cons:

Pros:

I don't know if this can have a positive impact on your monthly bills.

aaronpk commented 2 years ago

I could see storing an additional size, but I'm not sure what the other middle size would be for. There's a lot of avatars stored right now so it's not a trivial amount of additional storage requirements to do this.

Looks like Twitter considers 48x48 their "normal" size now. Maybe we should go straight down to that size as the new size to store?

I'm open to this but need to make sure whatever change I make is going to be the most useful to people.

nhoizey commented 2 years ago

I show them at 48×48 CSS pixels on my side, but use both 48×48 and 96×96 images to account for Retina screens with srcset-x.

It looks like Twitter does the same with both 48×48 and 96×96 (at least), but with a huge DOM and JS based image selection instead of simple standard HTML… 🤷‍♂️

It looks like @zachleat shows them at 48×48 CSS pixels too, but loads a single 72×72 image for everyone.

If you want to keep only one dimension, I guess 48×48 would be too small, so I would suggest 96×96.

aaronpk commented 1 year ago

I've changed the scaled avatar size to 96x96. I'm not going to go migrate the old avatars to the smaller resolution because there are almost 700k of them taking up 8gb. But all new avatars stored going forward will be at 96px.