IMAGEM
Transformação de imagem
Manda uma imagem (ou aponta uma URL), recebe de volta editada: corte, rotação, redimensionamento, ajuste de cor, efeitos, marca d'água e conversão entre seis formatos, tudo numa chamada só. Sem fila, sem callback: a resposta já é o arquivo pronto.
Image transform
Send an image (or point to a URL), get it back edited: crop, rotate, resize, color adjustments, effects, a watermark and conversion between six formats, all in one call. No queue, no callback: the response already is the finished file.
SYNC resposta na mesma chamada answers in the same call
Endpoint
Endpoint
/api/v1/imagem/transform
redimensiona e/ou converte uma imagem
resizes and/or converts an image
Entrada: PNG, JPEG, GIF, BMP, TIFF ou WebP, no corpo da requisição, ou use ?url= pra a própria API buscar a imagem em vez de você enviar os bytes. Toda edição roda numa pipeline fixa, na ordem geometria → cor → efeitos → marca d'água: os parâmetros abaixo são todos opcionais e independentes, aplicados só os que você passar. A resposta de sucesso é a imagem crua (Content-Type: image/{formato}), não o envelope JSON. Erros continuam vindo como JSON normalmente.
Input: PNG, JPEG, GIF, BMP, TIFF or WebP, in the request body, or use ?url= to have the API fetch the image instead of sending the bytes yourself. Every edit runs through a fixed pipeline, in the order geometry → color → effects → watermark: every parameter below is optional and independent, applying only what you pass. The success response is the raw image (Content-Type: image/{format}), not the JSON envelope. Errors still come back as JSON as usual.
Saída aceita PNG, JPEG, GIF, BMP ou TIFF (?format=). WebP fica de fora da saída: não existe hoje um encoder WebP pure-Go maduro o suficiente pra essa API, que roda sem CGO de propósito.
Output accepts PNG, JPEG, GIF, BMP or TIFF (?format=). WebP is left out of the output side: there's no WebP encoder in pure Go mature enough yet for this API, which deliberately runs without CGO.
Parâmetros
Parameters
| Nome | Name | Descrição | Description |
|---|---|---|---|
url | se presente, a API baixa a imagem dessa URL em vez de ler o corpo da requisição | if present, the API downloads the image from this URL instead of reading the request body |
Geometria
Geometry
crop | LARGURAxALTURA: corta o centro da imagem pra esse tamanho (1-4096px); 400 se maior que a imagem | WIDTHxHEIGHT: crops the center of the image to this size (1-4096px); 400 if bigger than the image |
rotate | graus, de -360 a 360: rotação livre, expande a tela e preenche o fundo transparente | degrees, -360 to 360: free rotation, expands the canvas and fills the background transparent |
flip | h, v ou hv: espelha horizontal, vertical ou ambos | h, v or hv: flips horizontally, vertically or both |
resize | LARGURAxALTURA (1-4096px); 0 num dos lados mantém a proporção automaticamente (ex.: 800x0) | WIDTHxHEIGHT (1-4096px); 0 on one side keeps the aspect ratio automatically (e.g. 800x0) |
Cor
Color
brightness | -100 a 100: brilho | -100 to 100: brightness |
contrast | -100 a 100: contraste | -100 to 100: contrast |
gamma | 0.01 a 10: correção gama (1 = sem mudança) | 0.01 to 10: gamma correction (1 = no change) |
saturation | -100 a 100: saturação | -100 to 100: saturation |
grayscale | true: escala de cinza | true: grayscale |
invert | true: inverte as cores | true: inverts the colors |
sepia | true: tom sépia clássico | true: classic sepia tone |
Efeitos
Effects
blur | 0.1 a 50: desfoque gaussiano (sigma) | 0.1 to 50: Gaussian blur (sigma) |
sharpen | 0.1 a 50: nitidez (unsharp mask, sigma) | 0.1 to 50: sharpen (unsharp mask, sigma) |
Marca d'água
Watermark
watermark_text | texto a desenhar (até 200 caracteres): não pode vir junto com watermark_url | text to draw (up to 200 characters): can't be combined with watermark_url |
watermark_url | URL de uma imagem pra usar como marca d'água: não pode vir junto com watermark_text | URL of an image to use as the watermark: can't be combined with watermark_text |
watermark_size | 8 a 500: tamanho da fonte em pt (padrão 32, só com watermark_text) | 8 to 500: font size in pt (default 32, text only) |
watermark_color | RRGGBB ou RRGGBBAA (padrão branco, só com watermark_text) | RRGGBB or RRGGBBAA (default white, text only) |
watermark_opacity | 1 a 100: opacidade (padrão 50, texto ou imagem) | 1 to 100: opacity (default 50, text or image) |
watermark_position | top-left, top-right, bottom-left, bottom-right (padrão) ou center | top-left, top-right, bottom-left, bottom-right (default) or center |
Saída
Output
format | padrão png: png, jpeg, jpg, gif, bmp ou tiff | defaults to png: png, jpeg, jpg, gif, bmp or tiff |
quality | padrão 90: só vale com format=jpeg, entre 1 e 100 | defaults to 90: only applies with format=jpeg, between 1 and 100 |
Exemplo
Example
# redimensiona e converte pra JPEG# resize and convert to JPEG
curl -X POST "https://api.alicercelabs.com.br/api/v1/imagem/transform?resize=200x200&format=jpeg&quality=85" \
-H "Authorization: Bearer <token>" \
--data-binary @foto-original.png \
-o miniatura.jpg
# pipeline completo numa chamada só: corta, rotaciona, tom de cinza, nitidez e marca d'água# full pipeline in one call: crop, rotate, grayscale, sharpen and a watermark
curl -X POST "https://api.alicercelabs.com.br/api/v1/imagem/transform?crop=200x200&rotate=15&grayscale=true&sharpen=1.5&watermark_text=AlicerceLabs&watermark_position=bottom-right&watermark_opacity=70" \
-H "Authorization: Bearer <token>" \
--data-binary @foto-original.png \
-o editada.png
# ou buscando de uma URL, saindo em WebP-in/TIFF-out# or fetching from a URL, WebP in / TIFF out
curl -X POST "https://api.alicercelabs.com.br/api/v1/imagem/transform?url=https://exemplo.com/foto.webp&resize=64x0&format=tiff" \
-H "Authorization: Bearer <token>" \
-o avatar.tiff
Erros possíveis
Possible errors
| Status | Motivo | Reason |
|---|---|---|
| 400 | corpo vazio ou não é uma imagem válida, algum parâmetro mal formado ou fora do intervalo aceito, crop maior que a imagem, ou watermark_text+watermark_url juntos | empty body or not a valid image, some parameter malformed or out of range, crop bigger than the image, or watermark_text+watermark_url together |
| 401 | token ausente ou inválido | missing or invalid token |
| 429 | limite de taxa excedido | rate limit exceeded |
| 503 | falha ao baixar a imagem de ?url= ou ?watermark_url= | failed to download the image from ?url= or ?watermark_url= |
Usando o SDK
Using the SDK
Uma de image/url é obrigatória, nunca as duas. Parâmetros de transformação (resize, format, grayscale, etc.) passam direto, sem precisar de um campo novo no SDK a cada parâmetro novo no servidor.
Exactly one of image/url is required, never both. Transform parameters (resize, format, grayscale, etc.) pass straight through, no new SDK field needed for every new server-side parameter.
SDKs oficiais: Go · Python · JavaScript.
Official SDKs: Go · Python · JavaScript.
Transformar uma imagem
Transform an image
import (
"context"
"fmt"
alicercelabs "github.com/alicercelabs/alicercesdk-go"
)
client := alicercelabs.New("alk_...")
ctx := context.Background()
img, err := os.ReadFile("foto.jpg")
params := url.Values{"resize": {"800x600"}, "format": {"webp"}, "quality": {"85"}}
out, err := client.Imagem.Transform(ctx, img, "", params)
out.Save("foto.webp")
// ou a partir de uma URL:
out, err = client.Imagem.Transform(ctx, nil, "https://exemplo.com/foto.jpg", params)from alicercelabs import AlicerceLabs
client = AlicerceLabs(api_key="alk_...")
with open("foto.jpg", "rb") as f:
out = client.imagem.transform(f.read(), resize="800x600", format="webp", quality=85)
out.save("foto.webp")
# ou a partir de uma URL:
out = client.imagem.transform(url="https://exemplo.com/foto.jpg", resize="800x600")import { AlicerceLabs } from "alicercesdk-javascript";
const client = new AlicerceLabs("alk_...");
const img = await readFile("foto.jpg");
const out = await client.imagem.transform({ image: img }, { resize: "800x600", format: "webp", quality: 85 });
await out.save("foto.webp");
// ou a partir de uma URL:
const fromUrl = await client.imagem.transform({ url: "https://exemplo.com/foto.jpg" }, { resize: "800x600" });Analisar sem transformar
Analyze without transforming
dimensões, cor dominante, paleta, BlurHash (o envelope JSON de sempre, não um arquivo).
dimensions, dominant color, palette, BlurHash (the usual JSON envelope, not a file).
info, err := client.Imagem.Analyze(ctx, img, "")
fmt.Println(info.Width, info.Height, info.DominantColor, info.BlurHash)info = client.imagem.analyze(img)
print(info["width"], info["height"], info["dominant_color"], info["blurhash"])const info = await client.imagem.analyze({ image: img });
console.log(info.width, info.height, info.dominant_color, info.blurhash);Limites
Limits
100/dia · 4/hora sem token, por IP chamador; com uma API key (gerada no painel), 1.000/dia · 41/hora. Upload máximo 10MB por padrão (corpo da requisição, o que é baixado via ?url=, ou via ?watermark_url=). Sem cache: cada combinação de parâmetros gera um resultado diferente, cada transformação é processada do zero. Parâmetros são validados antes da imagem ser decodificada. Um parâmetro inválido responde rápido, sem gastar tempo processando o arquivo.
100/day · 4/hour without a token, per calling IP; with an API key (generated in the panel), 1,000/day · 41/hour. Max upload 10MB by default (request body, whatever's downloaded via ?url=, or via ?watermark_url=). No caching: every parameter combination produces a different result, every transform is processed from scratch. Parameters are validated before the image is even decoded. An invalid parameter answers fast, without spending time processing the file.