# html2image **Repository Path**: zengd/html2image ## Basic Information - **Project Name**: html2image - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-14 - **Last Updated**: 2025-07-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HTML to Image Conversion Service 一个基于Spring Boot的HTML转图片服务,提供REST API接口。 ## 功能特性 - HTML/CSS转换为图片(PNG、JPEG) - 可配置视口大小和图片质量 - 自定义渲染延迟 - 完整的错误处理和验证 - 健康检查端点 ## 技术栈 - Java 17 - Spring Boot 3.2.0 - Microsoft Playwright - Maven ## 快速开始 ### 环境要求 - Java 17+ - Maven 3.6+ ### 运行服务 ```bash # 安装依赖 mvn clean install # 启动服务 mvn spring-boot:run ``` 服务启动后将在 `http://localhost:8080` 运行。 ### API 使用 #### 转换HTML为图片 ```bash POST /api/v1/html-to-image Content-Type: application/json { "html": "

Hello World

", "css": "h1 { color: blue; }", "options": { "format": "PNG", "width": 1920, "height": 1080, "quality": 90, "delay": 1000 } } ``` #### 健康检查 ```bash GET /api/v1/health ``` ## 配置 在 `application.properties` 中可以配置: ```properties # 浏览器超时时间 htmltoimage.browser.timeout=30000 # 默认视口大小 htmltoimage.browser.viewport.width=1920 htmltoimage.browser.viewport.height=1080 # 图片配置 htmltoimage.image.default-format=PNG htmltoimage.image.default-quality=90 htmltoimage.image.max-width=4096 htmltoimage.image.max-height=4096 ``` ## 运行测试 ```bash mvn test ```