@Provider
@Singleton
public class AvatarService
extends java.lang.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 java.awt.image.BufferedImage |
createThumbnail(java.awt.image.BufferedImage image,
java.awt.Color bg,
int target) |
Returns a thumbnail of the input image.
|
static java.awt.image.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,
java.io.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,
java.lang.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 java.io.IOException
user - The user (email must be populated).java.io.IOExceptionpublic boolean tryRemotePicture(org.minijax.db.NamedEntity user,
java.lang.String url,
int imageType)
throws java.io.IOException
user - The user.url - The profile picture URL.imageType - The avatar image type (see ajibot.common.model.Avatar).java.io.IOExceptionpublic static java.awt.image.BufferedImage createThumbnail(java.awt.image.BufferedImage image,
java.awt.Color bg,
int target)
image - The input image.bg - The background color.target - The target size.public static java.awt.image.BufferedImage generateAvatarImage()
public void generateAvatarImage(org.minijax.db.NamedEntity owner)
throws java.io.IOException
owner - The owner entity (user, organization, etc).java.io.IOExceptionpublic void handleFileUpload(org.minijax.db.NamedEntity entity,
java.io.InputStream file)
throws java.io.IOException
entity - The avatar entity (user, organization, device, etc).file - The alleged picture file.java.io.IOExceptionCopyright © 2018 Ajibot. All rights reserved.