The avatar resizer plugin will scale down VCard-based avatars, when the corresponding vCard is stored in Openfire
(it will not affect avatars that are being transferred between end-users).
</p>
<p>
Using avatars that are large can introduce problems for clients - not only will all of the data need to be
transferred (which is done with inefficient base64-encoding), some clients have trouble displaying large sets. RAM
and CPU spikes can occur as a result.
</p>
<p>
To prevent these problems, this plugin scales Avatars from vCards, but only if the vCards are provided by Openfire
itself (through one of its <ahref="https://www.igniterealtime.org/builds/openfire/docs/latest/documentation/javadoc/org/jivesoftware/openfire/vcard/VCardProvider.html">VCardProvider</a>
implementations, which include the default, database-oriented provider, an LDAP provider and a Atlassian Crowd
provider).
</p>
<p>
Avatar scaling of this plugin is in accordance with the guidelines listed in
Log.debug("Original image dimension ({}x{}) is within acceptable bounds ({}x{}). No need to resize.",avatar.getWidth(),avatar.getHeight(),targetDimension,targetDimension);
returnnull;
}
}
catch(IOException|RuntimeExceptionex)
{
Log.warn("Failed to resize avatar. An unexpected exception occurred while reading the original image.",ex);
returnnull;
}
/* We're going to be resizing, let's crop the image so that it's square and figure out the new starting size. */
Log.debug("Original image is "+avatar.getWidth()+"x"+avatar.getHeight()+" pixels");
finalinttargetWidth,targetHeight;
if(avatar.getHeight()==avatar.getWidth())
{
Log.debug("Original image is already square ({}x{})",avatar.getWidth(),avatar.getHeight());
targetWidth=targetHeight=avatar.getWidth();
}
else
{
finalintx,y;
if(avatar.getHeight()>avatar.getWidth())
{
Log.debug("Original image is taller ({}) than wide ({}).",avatar.getHeight(),avatar.getWidth());
x=0;
y=(avatar.getHeight()-avatar.getWidth())/2;
targetWidth=targetHeight=avatar.getWidth();
}
else
{
Log.debug("Original image is wider ({}) than tall ({}).",avatar.getWidth(),avatar.getHeight());