/** * 图片验证选项 */ export interface ImageValidationOptions { /** 最大文件大小(字节),默认不限制 */ maxSize?: number; /** 允许的文件扩展名(小写,包含点号),如 ['.jpg', '.png'] */ allowedFormats?: readonly string[]; /** 最小宽度(像素) */ minWidth?: number; /** 最大宽度(像素) */ maxWidth?: number; /** 最小高度(像素) */ minHeight?: number; /** 最大高度(像素) */ maxHeight?: number; } /** * 图片验证错误 */ export declare class ImageValidationError extends Error { code: number; data: string; constructor(message: string, code?: number, data?: string); } /** * 验证图片文件 * @param filePath 图片文件路径 * @param options 验证选项 * @param platformName 平台名称,用于错误提示 * @throws {ImageValidationError} 当验证失败时抛出错误 */ export declare function validateImageFile(filePath: string, options: ImageValidationOptions, platformName: string): void; /** * 各平台图片限制预设配置 */ export declare const PlatformImageLimits: { /** 百家号:5MB,仅支持 jpg、png */ readonly baijiahao: { readonly maxSize: number; readonly allowedFormats: readonly [".jpg", ".jpeg", ".png"]; }; /** 视频号:20MB */ readonly shipinhao: { readonly maxSize: number; }; /** 头条号:20MB,推荐 jpg、png 格式 */ readonly toutiao: { readonly maxSize: number; readonly allowedFormats: readonly [".jpg", ".jpeg", ".png"]; }; /** 抖音:50MB */ readonly douyin: { readonly maxSize: number; }; /** 小红书:32MB,支持多种格式 */ readonly xiaohongshu: { readonly maxSize: number; readonly allowedFormats: readonly [".jpg", ".jpeg", ".png", ".gif"]; }; }; /** * 使用预设配置验证图片 * @param filePath 图片文件路径 * @param platform 平台名称 */ export declare function validateImageByPlatform(filePath: string, platform: keyof typeof PlatformImageLimits): void;