crabcrop

v0.16.0
io.github.crabcrop/crabcrop Checked 5 hours ago Published 4 days ago

Sign and explain crabcrop image URLs, fetch processed-image metadata, and purge cached results.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

sign_url

Build and sign a crabcrop URL from an operation string and a source. Returns the full URL. Uses CRABCROP_BASE / CRABCROP_SECRET from the environment unless base/secret arguments override them; with no secret the URL carries the literal `unsafe` signature segment. Prefer the environment for the secret: per-call secret arguments are deprecated.

ParameterTypeDescription
operations *stringOperation string, e.g. "crop:1200x630:smart/filters:format(webp)"; may be empty and may contain preset: references.
source *stringSource locator: an http(s) URL, s3://bucket/key, gs://bucket/key, or file:// path.
basestringcrabcrop endpoint origin. Defaults to CRABCROP_BASE.
expiresnumberOptional unix-seconds expiry, emitted as an exp: segment.
keyIdstringOptional key ID stamped on the signature segment (`<key-id>:<tag>`) for servers running a secret rotation; they verify a keyed segment against the named key only.
secretstringSigning secret. Defaults to CRABCROP_SECRET; omit for unsafe URLs. Sensitive, deprecated: prefer the CRABCROP_SECRET environment variable; a per-call secret is kept in client transcripts.

explain_url

Parse a crabcrop URL back into its pieces: the signature kind, each operation segment with a plain-language explanation, exp: rendered as a UTC instant with an expired verdict, and the source. Malformed segments and unknown filters are reported as errors. A URL longer than 64 KiB is refused.

ParameterTypeDescription
url *stringThe full crabcrop URL or bare path.

fetch_meta

Fetch the crabcrop meta JSON for a URL (the processed result's width, height, format, byte size, quality, and placeholder data on request). The URL must already be signed if the server requires signatures. The server must have meta mode on (CRABCROP_META_MODE=1, off by default); without it the server answers 403 meta_disabled. For safety the URL's origin must match CRABCROP_BASE: this tool will not fetch arbitrary URLs. The meta JSON comes back unchanged as the first text block, and this note as a second one: provenance.source.signer and provenance.output.signer in the meta JSON are the names…

ParameterTypeDescription
url *stringThe full crabcrop URL.
placeholdersbooleanAlso request placeholder data (default false).

purge_result

Evict a cached result from a crabcrop server. The path is the cached URL's remainder after its signature (operations and source; a preset URL works as-is, the server expands it, and the exp: segments it opens with are dropped, since the cache key does not carry them). Requires the signing secret (argument or CRABCROP_SECRET). With expires, the purge URL carries that expiry and stops working at that second, which a server with CRABCROP_PURGE_REQUIRE_EXPIRY requires. Returns how many entries were removed. For safety the request only goes to /purge/ under the configured CRABCROP_BASE (a base argu…

ParameterTypeDescription
path *stringRemainder of the cached URL, e.g. "300x200/https://example.com/a.jpg".
basestringRedundant: the request always goes to CRABCROP_BASE, and a base argument must equal it (trailing slashes aside). Omit it.
expiresnumberOptional unix-seconds expiry for the purge URL, emitted as an exp: segment after the signature: the signature covers it, and the server refuses the purge from that second on.
secretstringSigning secret. Defaults to CRABCROP_SECRET. Sensitive, deprecated: prefer the CRABCROP_SECRET environment variable; a per-call secret is kept in client transcripts.