Package play.libs
Class Images
- java.lang.Object
-
- play.libs.Images
-
public class Images extends java.lang.Object
Images utils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Images.Captcha
A captcha image.
-
Constructor Summary
Constructors Constructor Description Images()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Images.Captcha
captcha()
Create a 150x150 captcha imagestatic Images.Captcha
captcha(int width, int height)
Create a captche imagestatic void
crop(java.io.File originalImage, java.io.File to, int x1, int y1, int x2, int y2)
Crop an imagestatic void
resize(java.io.File originalImage, java.io.File to, int w, int h)
Resize an imagestatic void
resize(java.io.File originalImage, java.io.File to, int w, int h, boolean keepRatio)
Resize an imagestatic java.lang.String
toBase64(java.io.File image)
Encode an image to base64 using a data: URI
-
-
-
Method Detail
-
resize
public static void resize(java.io.File originalImage, java.io.File to, int w, int h)
Resize an image- Parameters:
originalImage
- The image fileto
- The destination filew
- The new width (or -1 to proportionally resize)h
- The new height (or -1 to proportionally resize)
-
resize
public static void resize(java.io.File originalImage, java.io.File to, int w, int h, boolean keepRatio)
Resize an image- Parameters:
originalImage
- The image fileto
- The destination filew
- The new width (or -1 to proportionally resize) or the maxWidth if keepRatio is trueh
- The new height (or -1 to proportionally resize) or the maxHeight if keepRatio is truekeepRatio
- if true, resize will keep the original image ratio and use w and h as max dimensions
-
crop
public static void crop(java.io.File originalImage, java.io.File to, int x1, int y1, int x2, int y2)
Crop an image- Parameters:
originalImage
- The image fileto
- The destination filex1
- The new x originy1
- The new y originx2
- The new x endy2
- The new y end
-
toBase64
public static java.lang.String toBase64(java.io.File image) throws java.io.IOException
Encode an image to base64 using a data: URI- Parameters:
image
- The image file- Returns:
- The base64 encoded value
- Throws:
java.io.IOException
- Thrown if the encoding encounters any problems.
-
captcha
public static Images.Captcha captcha(int width, int height)
Create a captche image- Parameters:
width
- The width of the captcheheight
- The height of the captche- Returns:
- The given captcha
-
captcha
public static Images.Captcha captcha()
Create a 150x150 captcha image- Returns:
- The given captcha
-
-