Files
SnapOtter/apps/docs/th/tools/image/compress.md
T
SnapOtterandGitHub f858c4cea0 feat: clearer, disambiguated tool names across all surfaces (#520)
Renames 18 ambiguous or hard-to-search tool names so image tools self-qualify like the other modalities ("Compress" becomes "Compress Image"), and cleans up a few awkward names. Propagated across search (constants.ts), display (en.ts + 20 locales), the OpenAPI base spec + 20 locale specs, and the docs tool-page headings in 21 languages. Removes the duplicate "Normalize Audio" summary shared by the video and audio endpoints. Tool ids and routes are unchanged, so no API paths or bookmarks break.
2026-07-15 21:55:51 +08:00

63 lines
3.5 KiB
Markdown

---
description: "ลดขนาดไฟล์ภาพตามระดับคุณภาพหรือให้ได้ขนาดไฟล์เป้าหมาย"
i18n_source_hash: 342c5cf1f864
i18n_provenance: human
i18n_output_hash: cb7e7df3175b
---
# บีบอัดภาพ {#compress}
ลดขนาดไฟล์ภาพโดยการระบุระดับคุณภาพหรือขนาดไฟล์เป้าหมายเป็นกิโลไบต์ เครื่องมือใช้การค้นหาแบบไบนารีซ้ำ ๆ เพื่อให้ได้ขนาดเป้าหมายอย่างแม่นยำ
## API Endpoint {#api-endpoint}
`POST /api/v1/tools/image/compress`
รับข้อมูลฟอร์ม multipart พร้อมไฟล์ภาพและฟิลด์ JSON `settings`
## Parameters {#parameters}
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| mode | string | No | `"quality"` | โหมดการบีบอัด: `quality` หรือ `targetSize` |
| quality | number | No | `80` | ระดับคุณภาพ (1-100) ใช้เมื่อ mode เป็น `quality` |
| targetSizeKb | number | No | - | ขนาดไฟล์เป้าหมายเป็นกิโลไบต์ ใช้เมื่อ mode เป็น `targetSize` |
## Example Request {#example-request}
บีบอัดที่คุณภาพ 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}'
```
บีบอัดให้ได้ขนาดเป้าหมาย 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 {#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 {#notes}
- ในโหมด `quality` ค่าที่ต่ำกว่าจะให้ไฟล์ขนาดเล็กกว่าพร้อมสิ่งแปลกปลอมจากการบีบอัดมากขึ้น ค่า 80 เป็นค่าเริ่มต้นที่ดีสำหรับการใช้งานบนเว็บ
- ในโหมด `targetSize` เอนจินจะทำการบีบอัดซ้ำ ๆ เพื่อให้ได้ใกล้เคียงกับเป้าหมายมากที่สุดโดยไม่เกิน
- รูปแบบเอาต์พุตตรงกับรูปแบบอินพุต การบีบอัดจะใช้กับการเข้ารหัสดั้งเดิมของรูปแบบนั้น (เช่น คุณภาพ JPEG สำหรับไฟล์ JPEG, คุณภาพ WebP สำหรับไฟล์ WebP)
- หากยอมรับคุณภาพเริ่มต้น (80) ได้ คุณสามารถละเว้นพารามิเตอร์ `quality` ไปได้ทั้งหมด