mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
docs: organize tool pages by modality under /tools/<modality>/
Move all 157 tool pages into image/video/audio/pdf/data subfolders so URLs read /tools/<modality>/<id> (e.g. /tools/image/crop). Nest the image sub-categories under an Image group in the sidebar so the nav reads by modality. Add public/_redirects (301, clean + .html forms) mapping every old flat /tools/<id> URL to its new path so inbound links keep working. Rewrite all internal /tools links. Verified with a clean docs build (no dead links).
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
---
|
||||
description: Reduce image file size by quality level or to a target file size.
|
||||
---
|
||||
|
||||
# Compress
|
||||
|
||||
Reduce image file size by specifying a quality level or a target file size in kilobytes. The tool uses iterative binary search to hit size targets accurately.
|
||||
|
||||
## API Endpoint
|
||||
|
||||
`POST /api/v1/tools/image/compress`
|
||||
|
||||
Accepts multipart form data with an image file and a JSON `settings` field.
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Default | Description |
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| mode | string | No | `"quality"` | Compression mode: `quality` or `targetSize` |
|
||||
| quality | number | No | `80` | Quality level (1-100). Used when mode is `quality`. |
|
||||
| targetSizeKb | number | No | - | Target file size in kilobytes. Used when mode is `targetSize`. |
|
||||
|
||||
## Example Request
|
||||
|
||||
Compress to quality 60:
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:1349/api/v1/tools/image/compress \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@photo.jpg" \
|
||||
-F 'settings={"mode": "quality", "quality": 60}'
|
||||
```
|
||||
|
||||
Compress to target size of 200 KB:
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:1349/api/v1/tools/image/compress \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@photo.jpg" \
|
||||
-F 'settings={"mode": "targetSize", "targetSizeKb": 200}'
|
||||
```
|
||||
|
||||
## Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/photo.jpg",
|
||||
"originalSize": 2450000,
|
||||
"processedSize": 204800
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- In `quality` mode, lower values produce smaller files with more compression artifacts. A value of 80 is a good default for web use.
|
||||
- In `targetSize` mode, the engine performs iterative compression to get as close to the target as possible without exceeding it.
|
||||
- Output format matches the input format. The compression applies to the format's native encoding (e.g. JPEG quality for JPEG files, WebP quality for WebP files).
|
||||
- If the default quality (80) is acceptable, you can omit the `quality` parameter entirely.
|
||||
Reference in New Issue
Block a user