Expand description
媒体处理模块
提供图片、PDF、SVG 等媒体文件的处理功能
Structs§
- Image
Compression Config - 图片压缩配置
- Image
Dimensions - 图片尺寸信息
- Image
Result - 图片处理结果
- PdfRead
Result - PDF 读取结果
- SvgRender
Options - SVG 渲染选项
Enums§
- Media
Category - 媒体类别
- Media
Result - 媒体读取结果
- Media
Type - 媒体文件类型
Constants§
- DEFAULT_
SVG_ DPI - 默认 DPI
- IMAGE_
COMPRESSION_ CONFIG - MAX_
IMAGE_ TOKENS - 最大图片 token 数
- PDF_
MAX_ SIZE - PDF 最大文件大小 (32MB)
Statics§
- BINARY_
FILE_ BLACKLIST - 二进制文件黑名单 这些文件类型不应该被读取
- PDF_
EXTENSIONS - PDF 扩展名
- SUPPORTED_
IMAGE_ FORMATS - 支持的图片格式
Functions§
- detect_
media_ type - 检测文件的媒体类型
- estimate_
image_ dimensions - 估算图片尺寸(基于文件大小和格式)
- estimate_
image_ tokens - 估算图片的 token 消耗
- get_
media_ category - 根据 MIME 类型获取媒体类别
- get_
mime_ type_ from_ extension - 从文件扩展名推断 MIME 类型
- get_
mime_ type_ sync - 同步获取 MIME 类型(基于文件头 magic bytes)
- get_
svg_ dimensions - 获取 SVG 文件的原始尺寸
- is_
blacklisted_ file - 检查文件是否在黑名单中
- is_
pdf_ extension - 验证文件扩展名是否为 PDF
- is_
pdf_ supported - 检查是否支持 PDF
- is_
supported_ image_ format - 检查是否为支持的图片格式
- is_
supported_ media_ file - 检查文件是否为支持的媒体文件
- is_
svg_ render_ enabled - 检查是否启用 SVG 渲染
- read_
image_ file_ enhanced - 读取图片文件(增强版本,包含尺寸提取)
- read_
image_ file_ sync - 读取图片文件(同步版本,不压缩)
- read_
pdf_ file - 读取 PDF 文件并返回 base64
- read_
svg_ file - 读取 SVG 文件内容
- validate_
image_ file - 验证图片文件
- validate_
pdf_ file - 验证 PDF 文件是否有效
- validate_
svg_ file - 验证 SVG 文件