Class ImageUtils
java.lang.Object
org.nutz.img.Images
tech.riemann.nif.utils.ImageUtils
public class ImageUtils
extends org.nutz.img.Images
图片工具类,扩展自Images类,提供图片处理相关的工具方法
- Author:
- Kerbores(kerbores@riemann.tech)
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.nutz.img.Images
CHANNEL_BLUE, CHANNEL_GREEN, CHANNEL_RED, WATERMARK_BOTTOM_CENTER, WATERMARK_BOTTOM_LEFT, WATERMARK_BOTTOM_RIGHT, WATERMARK_CENTER, WATERMARK_CENTER_LEFT, WATERMARK_CENTER_RIGHT, WATERMARK_TOP_CENTER, WATERMARK_TOP_LEFT, WATERMARK_TOP_RIGHT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.nutz.lang.util.NutMap使用百度OCR服务识别图片中的文字static FilegenerateImage(String imgStr, File outFile) 将Base64字符串转换为图片文件static FilegenerateImage(String imgStr, File outDir, String suffix) 根据Base64串生成文件static FilegeneratePngImage(String imgStr) 生成png图片static StringgetImageStr(File imgFile) 图片转换成base64串static FiletoFile(BufferedImage bfi) 将 BufferedImage 写入文件static BufferedImagezoomAndClip(File src, double scale, int xStart, int yStart, int xEnd, int yEnd) 图片缩放裁剪static BufferedImagezoomAndClip(File src, double scale, ImageUtils.Point start, int w, int h) 根据指定的缩放比例和起始点,从源图像中裁剪出一个区域,并将其缩放为目标尺寸 此方法提供了从文件读取图像并进行裁剪和缩放的能力,适用于需要对图像特定区域进行处理的场景static BufferedImagezoomAndClip(File src, double scale, ImageUtils.Point start, ImageUtils.Point end) 图片缩放裁剪Methods inherited from class org.nutz.img.Images
addWatermark, channelImage, clipScale, clipScale, clipScale, clipScale, clipScale, clipScale, createAvatar, createAvatar, createCaptcha, createCaptcha, createText, createText, cutoutByChannel, cutoutByLuminance, cutoutByPixel, encodeBase64, encodeBase64, flipHorizontal, flipHorizontal, flipVertical, flipVertical, grayImage, multiply, read, redraw, rotate, rotate, rotate, scale, twist, write, write, writeAndClose, writeJpeg, zoomScale, zoomScale, zoomScale, zoomScale
-
Constructor Details
-
ImageUtils
public ImageUtils()
-
-
Method Details
-
zoomAndClip
public static BufferedImage zoomAndClip(File src, double scale, int xStart, int yStart, int xEnd, int yEnd) throws IOException 图片缩放裁剪- Parameters:
src- 源图scale- 缩放比例xStart- 起点X坐标yStart- 起点Y坐标xEnd- 终点X坐标yEnd- 终点Y坐标- Returns:
- 目标图片
- Throws:
IOException- 当读写文件失败时抛出
-
zoomAndClip
public static BufferedImage zoomAndClip(File src, double scale, ImageUtils.Point start, ImageUtils.Point end) throws IOException 图片缩放裁剪- Parameters:
src- 源图scale- 缩放比例start- 起点坐标end- 终点坐标- Returns:
- 目标图片
- Throws:
IOException- 当读写文件失败时抛出
-
toFile
将 BufferedImage 写入文件- Parameters:
bfi- BufferedImage图像- Returns:
- 写入的文件对象
-
zoomAndClip
public static BufferedImage zoomAndClip(File src, double scale, ImageUtils.Point start, int w, int h) throws IOException 根据指定的缩放比例和起始点,从源图像中裁剪出一个区域,并将其缩放为目标尺寸 此方法提供了从文件读取图像并进行裁剪和缩放的能力,适用于需要对图像特定区域进行处理的场景- Parameters:
src- 源图像文件,不能为空scale- 缩放比例,用于将裁剪得到的图像缩放至目标尺寸start- 裁剪区域的起始点,决定了从源图像中开始裁剪的位置w- 裁剪区域的宽度,表示需要裁剪的图像区域的水平尺寸h- 裁剪区域的高度,表示需要裁剪的图像区域的垂直尺寸- Returns:
- 返回经过裁剪和缩放处理后的BufferedImage对象
- Throws:
IOException- 如果读取或处理源文件时发生错误,则抛出IOException
-
generateImage
-
generateImage
-
generatePngImage
-
getImageStr
-
baiduOcr
-