From 0fdaf10e9269b5a2e83ba7cff14b96004ffe79ee Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Wed, 11 Jun 2025 11:07:12 +0800 Subject: [PATCH] add: README.md --- README.md | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec1a1e3 --- /dev/null +++ b/README.md @@ -0,0 +1,101 @@ +# ImageProxy + +ImageProxy 是一个高性能的图片代理服务,它能够自动下载、调整大小并优化图片,同时支持 WebP 格式转换。这个服务特别适合用于优化网站图片加载性能。 + +## 功能特点 + +- 支持 HTTP/HTTPS 图片源 +- 自动调整图片大小 +- 转换为 WebP 格式以减小文件大小 +- 支持自定义最大尺寸 +- 详细的性能指标输出 +- 内置 CORS 支持 +- 长期缓存支持 + +## 技术栈 + +- Rust +- Axum (Web 框架) +- Tokio (异步运行时) +- image-rs (图片处理) +- libwebp (WebP 转换) + +## 快速开始 + +### 使用 Docker + +```bash +docker run -p 2999:2999 your-imageproxy-image +``` + +### 从源码构建 + +1. 确保已安装 Rust 工具链 +2. 克隆仓库 +3. 构建项目: + +```bash +cargo build --release +``` + +4. 运行服务: + +```bash +./target/release/imageproxy +``` + +## 使用方法 + +### 基本用法 + +``` +http://your-server:2999/https://example.com/image.jpg +``` + +### 调整最大尺寸 + +``` +http://your-server:2999/max_size/500/https://example.com/image.jpg +``` + +## 响应头信息 + +服务会在响应中包含以下有用的头信息: + +- `Content-Type`: 始终为 `image/webp` +- `Cache-Control`: 设置为长期缓存 +- `X-Original-Content-Type`: 原始图片的 Content-Type +- `X-Original-Size`: 原始图片大小(字节) +- `X-Original-Width`: 原始图片宽度 +- `X-Original-Height`: 原始图片高度 +- `X-Output-Max-Size`: 输出图片的最大尺寸 +- `X-Converted-Size`: 转换后的图片大小 +- `X-Download-Time`: 下载耗时(毫秒) +- `X-Resize-Time`: 调整大小耗时(毫秒) +- `X-Convert-Time`: 转换耗时(毫秒) + +## 限制 + +- 最大支持下载 10MB 的图片 +- 仅支持图片格式的输入 +- 输出格式固定为 WebP + +## 环境变量 + +- `LISTEN`: 监听地址和端口(默认:0.0.0.0:2999) +- `RUST_LOG`: 日志级别(默认:info) + +## 性能优化 + +- 使用 WebP 格式进行高效压缩 +- 支持异步处理 +- 内置缓存控制 +- 优化的图片处理算法 + +## 许可证 + +[待定] + +## 贡献 + +欢迎提交 Issue 和 Pull Request! \ No newline at end of file