@Provider @Singleton public class AvatarService extends Object
| Modifier and Type | Field and Description |
|---|---|
static double |
RESIZE_FACTOR
Per the recommendations of the Java/Sun team, we do a multi step
image resize.
|
| Constructor and Description |
|---|
AvatarService() |
| Modifier and Type | Method and Description |
|---|---|
static BufferedImage |
createThumbnail(BufferedImage image,
Color bg,
int target)
Returns a thumbnail of the input image.
|
static BufferedImage |
generateAvatarImage()
Generates a new avatar image.
|
void |
generateAvatarImage(NamedEntity owner)
Uploads a generated profile picture for the user.
|
void |
handleFileUpload(NamedEntity entity,
InputStream file)
Uploads a new profile picture.
|
boolean |
tryGravatar(SecurityUser user)
Tries to fetch a remote Gravatar image.
|
boolean |
tryRemotePicture(NamedEntity user,
String url,
int imageType)
Tries to fetch a remote profile picture and set it as the user's avatar.
|
public static final double RESIZE_FACTOR
public boolean tryGravatar(SecurityUser user) throws IOException
user - The user (email must be populated).IOExceptionpublic boolean tryRemotePicture(NamedEntity user, String url, int imageType) throws IOException
user - The user.url - The profile picture URL.imageType - The avatar image type (see ajibot.common.model.Avatar).IOExceptionpublic static BufferedImage createThumbnail(BufferedImage image, Color bg, int target)
image - The input image.bg - The background color.target - The target size.public static BufferedImage generateAvatarImage()
public void generateAvatarImage(NamedEntity owner) throws IOException
owner - The owner entity (user, organization, etc).IOExceptionpublic void handleFileUpload(NamedEntity entity, InputStream file) throws IOException
entity - The avatar entity (user, organization, device, etc).file - The alleged picture file.IOExceptionCopyright © 2018 Ajibot. All rights reserved.