Class ThumbnailBuilder
java.lang.Object
cloud.opencode.base.image.thumbnail.ThumbnailBuilder
Thumbnail Builder
缩略图构建器
Fluent builder for creating Raster-based thumbnails with size,
crop, quality, and format options.
用于创建基于 Raster 的缩略图的流式构建器,支持尺寸、裁剪、质量和格式选项。
Usage Examples | 使用示例:
// Simple thumbnail
ThumbnailBuilder.of(imagePath)
.size(200, 200)
.save(thumbnailPath);
// With crop
ThumbnailBuilder.of(imageBytes)
.size(150, 150)
.crop(true)
.quality(0.85f)
.format(ImageFormat.JPEG)
.save(outputPath);
Security | 安全性:
- Thread-safe: No (mutable builder) - 线程安全: 否(可变构建器)
- Null-safe: No (throws on null source) - 空值安全: 否(null 源抛异常)
- Since:
- JDK 25, opencode-base-image V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty builder; set the source viasource(Path)orsource(Raster).ThumbnailBuilder(Raster source) Build from aRaster. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the thumbnail.buildRaster(Raster sourceRaster) Build a thumbnail from the suppliedRaster(overrides any previously configured source).voidcreate()Build the thumbnail and save to the configured output path.crop(boolean crop) format(ImageFormat format) height(int height) static ThumbnailBuilderof(byte[] bytes) Factory: from raw image bytes.static ThumbnailBuilderFactory: fromRaster.static ThumbnailBuilderFactory: fromImage.static ThumbnailBuilderFactory: from path.quality(float quality) voidBuild and save to path 构建并保存到路径size(int width, int height) byte[]toBytes()Build and return as bytes 构建并返回字节数组toImage()Build the thumbnail and wrap it in anImage.width(int width)
-
Constructor Details
-
ThumbnailBuilder
public ThumbnailBuilder()Empty builder; set the source viasource(Path)orsource(Raster). -
ThumbnailBuilder
-
-
Method Details
-
of
Factory: from path.- Throws:
ImageIOException
-
of
Factory: fromImage. -
of
Factory: fromRaster. -
of
Factory: from raw image bytes.- Throws:
ImageIOException
-
size
-
width
-
height
-
crop
-
quality
-
format
-
source
- Throws:
ImageIOException
-
source
-
source
-
output
-
create
Build the thumbnail and save to the configured output path. 构建缩略图并保存到已配置的输出路径。- Throws:
ImageWriteException
-
build
-
toImage
-
save
Build and save to path 构建并保存到路径- Throws:
ImageWriteException
-
toBytes
Build and return as bytes 构建并返回字节数组- Throws:
ImageOperationException
-
buildRaster
-