Files
SnapOtter/apps/docs/vi/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

2.5 KiB

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
Giảm kích thước tệp ảnh theo mức chất lượng hoặc theo kích thước tệp mục tiêu. 342c5cf1f864 human af62b2e13a07

Nén ảnh

Giảm kích thước tệp ảnh bằng cách chỉ định mức chất lượng hoặc kích thước tệp mục tiêu tính bằng kilobyte. Công cụ dùng tìm kiếm nhị phân lặp để đạt mục tiêu kích thước một cách chính xác.

API Endpoint

POST /api/v1/tools/image/compress

Chấp nhận dữ liệu form multipart với một tệp ảnh và một trường JSON settings.

Tham số

Tham số Kiểu Bắt buộc Mặc định Mô tả
mode string Không "quality" Chế độ nén: quality hoặc targetSize
quality number Không 80 Mức chất lượng (1-100). Dùng khi chế độ là quality.
targetSizeKb number Không - Kích thước tệp mục tiêu tính bằng kilobyte. Dùng khi chế độ là targetSize.

Ví dụ yêu cầu

Nén về chất lượng 60:

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}'

Nén về kích thước mục tiêu 200 KB:

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}'

Ví dụ phản hồi

{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/photo.jpg",
  "originalSize": 2450000,
  "processedSize": 204800
}

Ghi chú

  • Ở chế độ quality, giá trị thấp hơn tạo tệp nhỏ hơn với nhiều nhiễu nén hơn. Giá trị 80 là mặc định tốt cho dùng trên web.
  • Ở chế độ targetSize, engine thực hiện nén lặp để đạt gần mục tiêu nhất có thể mà không vượt quá.
  • Định dạng đầu ra khớp với định dạng đầu vào. Việc nén áp dụng cho mã hóa gốc của định dạng (ví dụ chất lượng JPEG cho tệp JPEG, chất lượng WebP cho tệp WebP).
  • Nếu chất lượng mặc định (80) chấp nhận được, bạn có thể bỏ hoàn toàn tham số quality.