[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80232":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":10,"openIssues":12,"contributorsCount":12,"subscribersCount":12,"size":12,"stars1d":13,"stars7d":13,"stars30d":13,"stars90d":12,"forks30d":12,"starsTrendScore":14,"compositeScore":15,"rankGlobal":8,"rankLanguage":8,"license":8,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":18,"hasPages":16,"topics":19,"createdAt":8,"pushedAt":8,"updatedAt":20,"readmeContent":21,"aiSummary":22,"trendingCount":12,"starSnapshotCount":12,"syncStatus":23,"lastSyncTime":24,"discoverSource":25},80232,"imgpress","hoanghiep2625\u002Fimgpress","hoanghiep2625",null,"JavaScript",58,33,0,1,3,4.59,false,"master",true,[],"2026-06-12 02:03:59","# ImgPress - Image Compression Service\n\nA high-performance batch image compression service built with Node.js and Sharp. Compress images to multiple formats (WebP, AVIF, PNG, JPEG, GIF) with smart quality optimization and resize capabilities.\n\n## Features\n\n- 🚀 **High-Performance**: Multi-format support with optimized compression algorithms\n- 📦 **Batch Processing**: Handle up to 20 files per request (up to 50MB each)\n- 🎨 **Multiple Formats**: WebP, AVIF, JPEG, PNG, GIF with auto-detection\n- 🔧 **Smart Optimization**: Automatic quality adjustment based on image properties\n- 📏 **Resize Support**: Optional width-based resizing with Lanczos3 kernel\n- 🌐 **Web UI**: Interactive drag-and-drop interface included\n- 🐳 **Docker Ready**: Production-ready Docker multi-stage build\n- ⚙️ **Highly Configurable**: Comprehensive environment variables\n\n## Quick Start\n\n### Prerequisites\n- Node.js 18+ or Docker\n\n### Installation\n\n```bash\n# Clone repository\ngit clone \u003Crepository-url>\ncd img-optimize\n\n# Install dependencies\ncd server\nnpm install\n\n# Run server\nnpm start\n```\n\nThe server will start on `http:\u002F\u002Flocalhost:3000`\n\n### Docker Setup\n\n```bash\n# Build image\ndocker build -t imgpress .\n\n# Run container\ndocker run -d \\\n  -p 3000:3000 \\\n  -e PORT=3000 \\\n  imgpress\n```\n\n## API Documentation\n\n### Compress Single Image\n\n**Endpoint:** `POST \u002Fcompress\u002Fone`\n\n**Request:**\n- Content-Type: `multipart\u002Fform-data`\n- Form field: `file` (required) - Image file to compress\n\n**Query Parameters:**\n\n| Parameter | Type | Default | Description |\n|-----------|------|---------|-------------|\n| `format` | string | `webp` | Output format: `webp`, `avif`, `jpeg`, `png`, `gif`, or `auto` (detect from input) |\n| `quality` | number | `80` | Compression quality (1-100). Auto-capped based on format for optimal results |\n| `width` | number | `1600` | Max width in pixels. Image won't be enlarged if smaller |\n\n**Response (Success):**\n```json\n{\n  \"name\": \"photo.jpg\",\n  \"mime\": \"image\u002Fwebp\",\n  \"originalSize\": 2048576,\n  \"compressedSize\": 614400,\n  \"savedBytes\": 1434176,\n  \"ratio\": 70.0,\n  \"data\": \"UklGRi4AAABXRUJQVlA4IBoAAAA...\",\n  \"error\": false\n}\n```\n\n**Response (Error):**\n```json\n{\n  \"name\": \"photo.jpg\",\n  \"originalSize\": 2048576,\n  \"error\": true,\n  \"message\": \"Image too large: 25000×25000px (max 20000px per side)\"\n}\n```\n\n**cURL Example:**\n```bash\n# Basic compression\ncurl -X POST \\\n  -F \"file=@image.jpg\" \\\n  http:\u002F\u002Flocalhost:3000\u002Fcompress\u002Fone\n\n# Custom format and quality\ncurl -X POST \\\n  -F \"file=@image.jpg\" \\\n  \"http:\u002F\u002Flocalhost:3000\u002Fcompress\u002Fone?format=avif&quality=75&width=1200\"\n\n# Auto-detect format\ncurl -X POST \\\n  -F \"file=@image.jpg\" \\\n  \"http:\u002F\u002Flocalhost:3000\u002Fcompress\u002Fone?format=auto\"\n```\n\n**JavaScript Example:**\n```javascript\nconst formData = new FormData();\nformData.append('file', fileInput.files[0]);\n\nconst response = await fetch('\u002Fcompress\u002Fone?format=webp&quality=80&width=1600', {\n  method: 'POST',\n  body: formData\n});\n\nconst result = await response.json();\nif (!result.error) {\n  \u002F\u002F Download or display compressed image\n  const imageBuffer = Buffer.from(result.data, 'base64');\n  \u002F\u002F ... handle image\n}\n```\n\n## Configuration\n\nServer behavior is controlled via environment variables:\n\n```bash\n# Port & Timeouts\nPORT=3000\nSERVER_TIMEOUT_MS=300000\nKEEP_ALIVE_TIMEOUT_MS=360000\nHEADERS_TIMEOUT_MS=361000\nCOMPRESS_TIMEOUT_MS=300000\n\n# Image Size Limits\nMAX_IMAGE_SIDE_PX=20000          # Max width\u002Fheight per side\nMAX_IMAGE_MEGAPIXELS=200          # Max total megapixels\nMAX_FILE_SIZE_MB=50               # Max file size per upload\nMAX_FILES=20                       # Max files per request\n\n# Compression Defaults\nDEFAULT_QUALITY=80                # Default quality (1-100)\nDEFAULT_WIDTH=1600                # Default resize width\nMAX_QUALITY_NO_ALPHA=85           # Max quality for images without alpha\nMAX_QUALITY_WITH_ALPHA=90         # Max quality for images with alpha\n\n# Advanced\nDITHER_MAX=0.7                    # Dither amount for PNG (max)\nDITHER_MIN=0.3                    # Dither amount for PNG (min)\nSHARP_CONCURRENCY=0               # 0 = auto, >0 = limit concurrent operations\n```\n\n## Performance Notes\n\n### Supported Formats & Optimization\n\n| Format | Best For | Default Quality | Notes |\n|--------|----------|-----------------|-------|\n| **WebP** | Web delivery | 80 | Modern browsers, excellent quality\u002Fsize ratio |\n| **AVIF** | Maximum compression | 70 | Newest format, slower encoding, best compression |\n| **JPEG** | Compatibility | 85 | Universal support, no transparency |\n| **PNG** | Lossless\u002FTransparency | 90 | Larger files, preserves quality |\n| **GIF** | Animation | 80 | Animated images, limited colors |\n\n### Smart Quality Adjustment\n\nThe service automatically caps quality based on image properties:\n- Images without alpha channel → capped at `MAX_QUALITY_NO_ALPHA` (85)\n- Images with transparency → capped at `MAX_QUALITY_WITH_ALPHA` (90)\n- This ensures optimal file size without quality degradation\n\n### Image Processing\n\n- **Resize**: Uses Lanczos3 kernel for high-quality downsampling\n- **Color Space**: Converts to sRGB for consistent output\n- **Optimization**: \n  - JPEG: MozJPEG + progressive encoding + optimized scanning\n  - PNG: Maximum compression + adaptive filtering + dithering\n  - AVIF: 4:2:0 chroma subsampling for better compression\n  - GIF: Frame analysis + dithering for smooth gradients\n\n## Web UI\n\nOpen `http:\u002F\u002Flocalhost:3000` in your browser to access the ImgPress web interface with:\n- Drag & drop image upload\n- Format selection\n- Quality control\n- Real-time compression stats\n- Batch processing\n\n## Development\n\n### Project Structure\n\n```\nimg-optimize\u002F\n├── server\u002F\n│   ├── server.js         # Express server & compression logic\n│   └── package.json      # Dependencies\n├── client\u002F\n│   ├── index.html        # Web UI\n│   ├── script.js         # Frontend logic\n│   └── styles.css        # Styling\n├── Dockerfile            # Container configuration\n└── README.md             # This file\n```\n\n### Local Development\n\n```bash\ncd server\nnpm install\nnpm start\n```\n\nVisit `http:\u002F\u002Flocalhost:3000`\n\n## Size Limits\n\n- **Per File**: 50 MB max\n- **Per Request**: 20 files max\n- **Image Dimensions**: 20,000 px per side max\n- **Total Megapixels**: 200 MP max\n\n## Error Handling\n\nCommon error messages:\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `file required` | No file in request | Include `file` in form data |\n| `Image too large: WxHpx` | Exceeds MAX_IMAGE_SIDE_PX | Request pre-resized image or adjust limit |\n| `Image too large: NMP` | Exceeds MAX_IMAGE_MEGAPIXELS | Request lower resolution image |\n| `Processing timeout` | Server busy | Reduce quality\u002Fdisable processing, retry |\n\n## CORS\n\nThe API accepts requests from all origins. Customize CORS in `server.js` if needed:\n\n```javascript\nres.setHeader('Access-Control-Allow-Origin', '*') \u002F\u002F Change '*' to specific domain\n```\n\n## License\n\nMIT\n\n## Support\n\nFor issues, features, or questions, please open an issue on the repository.\n","ImgPress 是一个基于 Node.js 和 Sharp 构建的高性能批量图像压缩服务。它支持多种格式（WebP、AVIF、PNG、JPEG、GIF）的智能质量优化和尺寸调整，能够处理每个请求最多 20 个文件（每个文件最大 50MB）。核心功能包括自动质量调整、基于 Lanczos3 内核的宽度调整以及通过环境变量进行高度配置。此外，项目提供了一个交互式的拖放 Web 界面，并且支持 Docker 多阶段构建，方便部署到生产环境。适用于需要高效处理大量图片并希望减少存储空间和提高加载速度的场景，如网站、移动应用或内容管理系统。",2,"2026-06-11 03:59:44","CREATED_QUERY"]