I’m not sure if the following is complete, but this rails console command removes all optimized images then regenerates the ones used for avatars:
OptimizedImage.destroy_all
UserAvatar.all.each {|ua| uaid = ua.gravatar_upload_id || ua.custom_upload_id; Jobs::CreateAvatarThumbnails.perform_async(upload_id: uaid) if uaid }