A simple method to support small buddy icons in Jabber has been an often
requested feature. Here is a proposal that was generated for how this could be
achieved.
First, the requirements on the image. The image must be between 32x32 and
64x64 pixels in size. The should be 64x64 and square if possible. It must be
either GIF, PNG, or JPEG format, as well as under 8k of data. More formats
may be acceptable in the future, and the protocol is designed around supporting
more. It is highly suggested to never scale images up.
To let other clients know that you support the buddy icons and have one
available a new x namespace is sent out with the initial presence. If the user
changes the icon, or disables the icon, a new presence update is sent out with
the correct information. Disabling is done sending the x tag with no hash
information. If a presence tag is received with no avatar information, it is
recommended that the client save the avatar icon until the next set of
information is received.
Examples:
- First login, and user has icon:
00000000000000000000000000000000000000000
- User changes their icon:
1111111111111111111111111111111111111111
- User disables their icon:
- Unknown action, cache avatar and await more information:
The hash is the SHA1 digest of the icon's data, and is sent so that the client
can store user images across sessions and not have to request the icon as often.
It is important in the case where no information is available (possibly
resulting from an unexpected disconnect), so that you do not have to
constantly request the avatar from the user when they reconnect.
There are two methods for the retrieval of the actual avatar data. The first
that should be attempted is a request sent directly to the other client using
an iq tag. Replies to the iq contain the mime type of the image as well as the
data, base64 encoded. If that fails, the next method that should be attempted
is a request to the server for the users public XML with the avatar data. The
data is to be stored in the storage:client:avatar
Examples:
- Setting the data to public xml:
Base64 Encoded Data
- Requesting the data from public xml:
- Request the icon using iq:
- Sending the icon using iq:
Base64 Encoded Data