mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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.
2.8 KiB
2.8 KiB
description, i18n_source_hash, i18n_provenance, i18n_output_hash
| description | i18n_source_hash | i18n_provenance | i18n_output_hash |
|---|---|---|---|
| Ubah ukuran gambar berdasarkan piksel, persentase, atau dengan mode fit. | 53866e8266b8 | human | c35e9fa1bead |
Ubah Ukuran Gambar
Ubah ukuran gambar dengan menentukan dimensi piksel persis, faktor skala persentase, atau mode fit yang mengontrol bagaimana gambar menyesuaikan dengan dimensi target.
API Endpoint
POST /api/v1/tools/image/resize
Menerima multipart form data dengan berkas gambar dan field JSON settings.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| width | integer | No | - | Lebar target dalam piksel (maks 16383) |
| height | integer | No | - | Tinggi target dalam piksel (maks 16383) |
| fit | string | No | "contain" |
Bagaimana gambar disesuaikan dengan dimensi: contain, cover, fill, inside, outside |
| withoutEnlargement | boolean | No | false |
Cegah pembesaran jika gambar lebih kecil dari target |
| percentage | number | No | - | Skalakan berdasarkan persentase (mis. 50 untuk setengah ukuran) |
Setidaknya salah satu dari width, height, atau percentage harus disediakan.
Fit Modes
- contain - Ubah ukuran agar pas di dalam dimensi, mempertahankan rasio aspek (mungkin menyisakan ruang kosong)
- cover - Ubah ukuran agar menutupi dimensi, mempertahankan rasio aspek (mungkin memotong)
- fill - Regangkan agar persis sesuai dimensi (mengabaikan rasio aspek)
- inside - Seperti
contain, tetapi hanya memperkecil, tidak pernah memperbesar - outside - Seperti
cover, tetapi hanya memperkecil, tidak pernah memperbesar
Example Request
curl -X POST http://localhost:1349/api/v1/tools/image/resize \
-H "Authorization: Bearer si_your-api-key" \
-F "file=@photo.jpg" \
-F 'settings={"width": 800, "height": 600, "fit": "contain"}'
Ubah ukuran berdasarkan persentase:
curl -X POST http://localhost:1349/api/v1/tools/image/resize \
-H "Authorization: Bearer si_your-api-key" \
-F "file=@photo.jpg" \
-F 'settings={"percentage": 50}'
Example Response
{
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/photo.jpg",
"originalSize": 2450000,
"processedSize": 980000
}
Notes
- Dimensi maksimum adalah 16383 piksel pada salah satu sumbu (batas Sharp/libvips).
- Format output mengikuti format input. Input HEIC, RAW, PSD, dan SVG didekode secara otomatis sebelum diproses.
- Orientasi EXIF diterapkan otomatis sebelum pengubahan ukuran.
- Flag
withoutEnlargementberguna untuk pemrosesan batch di mana beberapa gambar mungkin sudah lebih kecil dari target.