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 |
限定符 | 构造器和说明 |
---|---|
private |
ImageUtils() |
限定符和类型 | 方法和说明 |
---|---|
static void |
drawImage(int width,
int height,
java.lang.String text,
java.io.OutputStream outputStream)
@RequestMapping(value = "getCaptchaImage")
public ResponseEntity<StreamingResponseBody> getCaptchaImage(HttpSession session) {
String captcha = VerificationUtils.getRandomString("ABCDEFGHJKMNPQRSTUVWXYZ23456789", 4);
session.setAttribute("captcha", captcha);
StreamingResponseBody body = new StreamingResponseBody() {
@Override
public void writeTo(OutputStream outputStream) throws IOException {
ImageUtils.drawImage(120, 30, captcha, outputStream);
}
};
return ResponseEntity.ok().body(body);
}
@PostMapping("doLogin")
public String login(@RequestAttribute SysSite site, HttpSession session, String username, String password, String captcha,
String returnUrl, Long clientId, String uuid, HttpServletRequest request, 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.lang.String icoFilepath) |
static void |
image2Webp(java.lang.String imageFilepath,
java.lang.String webpFilepath) |
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.InputStream webpInputStream,
boolean png,
java.lang.String imageFilepath) |
static void |
webp2Image(java.lang.String webpFilepath,
boolean png,
java.lang.String imageFilepath) |
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 ResponseEntity<StreamingResponseBody> getCaptchaImage(HttpSession session) { String captcha = VerificationUtils.getRandomString("ABCDEFGHJKMNPQRSTUVWXYZ23456789", 4); session.setAttribute("captcha", captcha); StreamingResponseBody body = new StreamingResponseBody() { @Override public void writeTo(OutputStream outputStream) throws IOException { ImageUtils.drawImage(120, 30, captcha, outputStream); } }; return ResponseEntity.ok().body(body); }
@PostMapping("doLogin") public String login(@RequestAttribute SysSite site, HttpSession session, String username, String password, String captcha, String returnUrl, Long clientId, String uuid, HttpServletRequest request, ModelMap model) { String sessionCaptcha = (String) session.getAttribute("captcha"); session.removeAttribute("captcha"); if (null != sessionCaptcha && sessionCaptcha.equalsIgnoreCase(captcha)) { // login code } else { return CommonUtils.joinString(UrlBasedViewResolver.REDIRECT_URL_PREFIX, "login.html"); } }
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.lang.String imageFilepath) throws java.io.IOException
java.io.IOException
public static void webp2Image(java.lang.String webpFilepath, boolean png, java.lang.String imageFilepath) throws java.io.IOException
java.io.IOException
public static void image2Webp(java.lang.String imageFilepath, java.lang.String webpFilepath) throws java.io.IOException
java.io.IOException
public static void image2Ico(java.io.InputStream input, java.lang.String suffix, int size, java.lang.String icoFilepath) 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)
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