public class ImageUtils
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
DEFAULT_FORMAT_NAME |
static java.lang.String |
FORMAT_NAME_JPG |
static java.lang.String |
FORMAT_NAME_PNG |
static java.lang.String |
FORMAT_NAME_SVG |
static java.lang.String |
FORMAT_NAME_WEBP |
private static org.apache.commons.logging.Log |
log |
构造器和说明 |
---|
ImageUtils() |
限定符和类型 | 方法和说明 |
---|---|
static void |
drawImage(int width,
int height,
java.lang.String text,
java.io.OutputStream outputStream)
@RequestMapping(value = "getCaptchaImage")
public void getCaptchaImage(javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletResponse response) {
try {
String captcha = VerificationUtils.getRandomString("ABCDEFGHJKMNPQRSTUVWXYZ23456789", 4);
session.setAttribute("captcha", captcha);
ImageUtils.drawImage(120, 30, captcha, response.getOutputStream());
} catch (IOException e) {
}
}
@RequestMapping(value = "doLogin", method = RequestMethod.POST)
public String login(@RequestAttribute SysSite site, javax.servlet.http.HttpSession session, String username,
String password, String captcha, String returnUrl, Long clientId, String uuid,
javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ModelMap model) {
String sessionCaptcha = (String) session.getAttribute("captcha");
session.removeAttribute("captcha");
if (null !
|
private static java.awt.Font |
getFont(int size) |
static java.lang.String |
getImageData(int width,
int height,
java.lang.String text) |
private static java.awt.Color |
getRandColor(int fc,
int bc) |
static void |
image2Ico(java.io.InputStream input,
java.lang.String suffix,
int size,
java.io.File icoFile) |
static void |
image2Webp(java.io.File imageFile,
java.io.File webpFile) |
private static void |
shearX(java.awt.Graphics g,
int w1,
int h1,
java.awt.Color color) |
static boolean |
svgSafe(java.io.File imageFile) |
static java.awt.image.BufferedImage |
thumb(java.awt.image.BufferedImage sourceImage,
int width,
int height,
boolean png) |
static void |
thumb(java.lang.String sourceFilePath,
java.lang.String thumbFilePath,
int width,
int height,
java.lang.String suffix) |
static void |
webp2Image(java.io.File webpFile,
boolean png,
java.io.File imageFile) |
static void |
webp2Image(java.io.InputStream webpInputStream,
boolean png,
java.io.File imageFile) |
private static final org.apache.commons.logging.Log log
public static final java.lang.String FORMAT_NAME_PNG
public static final java.lang.String FORMAT_NAME_JPG
public static final java.lang.String FORMAT_NAME_WEBP
public static final java.lang.String FORMAT_NAME_SVG
public static final java.lang.String DEFAULT_FORMAT_NAME
public static java.lang.String getImageData(int width, int height, java.lang.String text) throws java.io.IOException
width
- height
- text
- java.io.IOException
public static void drawImage(int width, int height, java.lang.String text, java.io.OutputStream outputStream) throws java.io.IOException
@RequestMapping(value = "getCaptchaImage") public void getCaptchaImage(javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletResponse response) { try { String captcha = VerificationUtils.getRandomString("ABCDEFGHJKMNPQRSTUVWXYZ23456789", 4); session.setAttribute("captcha", captcha); ImageUtils.drawImage(120, 30, captcha, response.getOutputStream()); } catch (IOException e) { } }
@RequestMapping(value = "doLogin", method = RequestMethod.POST) public String login(@RequestAttribute SysSite site, javax.servlet.http.HttpSession session, String username, String password, String captcha, String returnUrl, Long clientId, String uuid, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ModelMap model) { String sessionCaptcha = (String) session.getAttribute("captcha"); session.removeAttribute("captcha"); if (null != sessionCaptcha && sessionCaptcha.equalsIgnoreCase(captcha)) { // login code } }
width
- height
- text
- outputStream
- java.io.IOException
private static void shearX(java.awt.Graphics g, int w1, int h1, java.awt.Color color)
private static java.awt.Color getRandColor(int fc, int bc)
private static java.awt.Font getFont(int size)
public static void webp2Image(java.io.InputStream webpInputStream, boolean png, java.io.File imageFile) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public static void webp2Image(java.io.File webpFile, boolean png, java.io.File imageFile) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public static void image2Webp(java.io.File imageFile, java.io.File webpFile) throws java.io.IOException
java.io.IOException
public static void image2Ico(java.io.InputStream input, java.lang.String suffix, int size, java.io.File icoFile) throws java.io.IOException
java.io.IOException
public static boolean svgSafe(java.io.File imageFile) throws java.io.IOException
java.io.IOException
public static java.awt.image.BufferedImage thumb(java.awt.image.BufferedImage sourceImage, int width, int height, boolean png) throws java.io.IOException
java.io.IOException
public static void thumb(java.lang.String sourceFilePath, java.lang.String thumbFilePath, int width, int height, java.lang.String suffix) throws java.io.IOException
java.io.IOException