/api/process?url={imageUrl}&w=&h=&format=&fit=&q=
Scarica un'immagine da un URL esterno, applica le trasformazioni richieste e restituisce l'immagine elaborata. Se non viene specificata nessuna trasformazione, restituisce l'immagine originale.
| Parametro | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
url | string | ✦ sì | URL completo dell'immagine sorgente (http o https) |
w | integer | no | Larghezza target in pixel |
h | integer | no | Altezza target in pixel |
format | string | no | jpeg · png · webp · avif |
fit | string | no | Modalità di resize (default: inside). Vedi tabella fit. |
q | integer | no | Qualità 1–100 (default: 80). Ignorato per PNG. |
# Converti in WebP 800px di larghezza (proporzionale)
GET /api/process?url=https://example.com/photo.jpg&w=800&format=webp
# Crop fisso 940×1358, qualità 85
GET /api/process?url=https://example.com/photo.jpg&w=940&h=1358&fit=cover&format=webp&q=85
# Solo conversione formato, nessun resize
GET /api/process?url=https://example.com/photo.jpg&format=avif&q=70
# Immagine originale senza trasformazioni
GET /api/process?url=https://example.com/photo.jpg
/api/images/{filename}?w=&h=&format=&fit=&q=
Serve un'immagine dalla cartella images/ del server applicando le trasformazioni richieste. Stessi parametri di /api/process, senza il parametro url.
| Parametro | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
filename (path) | string | ✦ sì | Nome del file in images/, es. product.jpg |
w | integer | no | Larghezza target in pixel |
h | integer | no | Altezza target in pixel |
format | string | no | jpeg · png · webp · avif |
fit | string | no | Modalità di resize (default: inside) |
q | integer | no | Qualità 1–100 (default: 80) |
# Thumbnail 240×347, crop, WebP
GET /api/images/product.jpg?w=240&h=347&fit=cover&format=webp
# Breakpoint srcset 768px, proporzionale
GET /api/images/product.jpg?w=768&format=webp
# Originale senza trasformazioni
GET /api/images/product.jpg
/api/images/list
Restituisce un array JSON con i nomi dei file presenti nella cartella images/. Formati supportati: jpg, jpeg, png, webp, avif. I file nascosti (.name) sono esclusi.
["product_01.jpg", "hero_banner.png", "thumbnail.webp"]
/api/processImage
Riceve un'immagine nel body (multipart o JSON/base64) e applica l'operazione richiesta. Restituisce il buffer dell'immagine elaborata.
| Campo | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
image | file / base64 | ✦ sì | Immagine sorgente (multipart: file binario; JSON: stringa base64) |
operation | string | ✦ sì | resizeFixed · resizeProportional · convertFormat · stripMetadata |
width | integer | no | Larghezza target |
height | integer | no | Altezza target |
format | string | no | jpeg · png · webp · avif |
fit | string | no | Modalità resize (default: cover) |
quality | integer | no | Qualità 1–100 (default: 80) |
stripMeta | boolean | no | Rimuovi metadati EXIF/GPS (default: true) |
curl -X POST http://46.62.134.81:7071/api/processImage \
-F "image=@photo.jpg" \
-F "operation=resizeFixed" \
-F "width=800" \
-F "height=600" \
-F "fit=cover" \
-F "format=webp" \
-o output.webp
curl -X POST http://46.62.134.81:7071/api/processImage \
-H "Content-Type: application/json" \
-d '{
"image": "'$(base64 -i photo.jpg)'",
"operation": "convertFormat",
"format": "avif",
"quality": 70
}' \
--output output.avif
Controlla come l'immagine viene adattata alle dimensioni target quando vengono specificati sia w che h.
| Valore | Comportamento | Ritaglia? | Deforma? |
|---|---|---|---|
cover | Riempie esattamente w×h, può tagliare i bordi | ✓ sì | no |
contain | Scala dentro w×h mantenendo le proporzioni, aggiunge bande | no | no |
inside | Scala dentro w×h senza mai ingrandire né ritagliare (default) | no | no |
fill | Deforma l'immagine per riempire esattamente w×h | no | ✓ sì |
outside | Scala finché almeno una dimensione raggiunge w×h (può eccedere) | no | no |
cover per thumbnail prodotto a dimensioni fisse (es. PDP, PLP), inside per srcset responsive dove non vuoi ritagliare.