]> git.openstreetmap.org Git - rails.git/commit
Normalise avatars when they are uploaded
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 18 Nov 2026 16:37:15 +0000 (16:37 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Thu, 19 Nov 2026 11:38:59 +0000 (11:38 +0000)
commitd79ae14b3638d9fe28e3ca395dae0c8fd0853403
treec2b492fd710a5cded8960110477ec506ae5941c6
parent41dba640b68df0b2d521f9ff866fe03427757bc1
Normalise avatars when they are uploaded

Re-encode newly uploaded avatars before they are stored, so that the
original upload is never stored or served. The stored image fits within
512x512 pixels, is rotated upright, converted to sRGB, has only the
first frame of any animation, and has all metadata (such as EXIF GPS
location) stripped. Non-web formats are stored as PNG, and the filename
is replaced, since it's visible in avatar URLs.

This is done synchronously, since processing a large photo takes well
under 100ms, and doing it in the background would mean the original
reaching storage (and any backups of it) first.
.rubocop_todo.yml
app/models/user.rb
lib/avatar_normaliser.rb [new file with mode: 0644]
test/controllers/profiles/images_controller_test.rb
test/helpers/user_helper_test.rb
test/models/user_test.rb