@Provider @Singleton public class AvatarService extends Object
| Modifier and Type | Field | Description |
|---|---|---|
static double |
RESIZE_FACTOR |
Per the recommendations of the Java/Sun team, we do a multi step
image resize.
|
| Constructor | Description |
|---|---|
AvatarService() |
| Modifier and Type | Method | 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(org.minijax.db.NamedEntity owner) |
Uploads a generated profile picture for the user.
|
void |
handleFileUpload(org.minijax.db.NamedEntity entity,
InputStream file) |
Uploads a new profile picture.
|
boolean |
tryGravatar(org.minijax.security.SecurityUser user) |
Tries to fetch a remote Gravatar image.
|
boolean |
tryRemotePicture(org.minijax.db.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(org.minijax.security.SecurityUser user)
throws IOException
user - The user (email must be populated).IOExceptionpublic boolean tryRemotePicture(org.minijax.db.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(org.minijax.db.NamedEntity owner)
throws IOException
owner - The owner entity (user, organization, etc).IOExceptionpublic void handleFileUpload(org.minijax.db.NamedEntity entity,
InputStream file)
throws IOException
entity - The avatar entity (user, organization, device, etc).file - The alleged picture file.IOExceptionCopyright © 2019 Ajibot. All rights reserved.