Skip to content

feat(get): retrieve/download an image (optionally transformed)#2

Merged
facundofarias merged 2 commits into
mainfrom
feat/get-download-command
Jul 7, 2026
Merged

feat(get): retrieve/download an image (optionally transformed)#2
facundofarias merged 2 commits into
mainfrom
feat/get-download-command

Conversation

@facundofarias

Copy link
Copy Markdown
Member

The CLI could upload / list / delete but had no way to retrieve an image's bytes. Adds a get command.

pixelvault get <id>

  • prints the CDN URL to stdout (agent-friendly, mirrors list)
  • --json → full metadata
  • -o/--output <file>download the image to disk
  • -t/--transform "<params>" → apply transform params to the URL / downloaded variant
pixelvault get img_xyz                              # print the CDN URL
pixelvault get img_xyz -o photo.png                 # download the original
pixelvault get img_xyz -o cut.png -t "segment=foreground"   # download a transparent cut-out
pixelvault get img_xyz -t "w=400&fmt=webp"          # just print the transformed URL

Ties the new transform capabilities into the CLI: download a thumbnail, cut-out, or watermarked variant in one call.

Notes

  • Output contract preserved: URL → stdout, human messages → stderr.
  • applyTransform tolerates a leading ?/&; unit-tested (+ metadata fetch). 16 tests pass; typecheck clean; build ok; get --help verified.
  • Not bumped/published — version stays 0.1.0; a minor bump + npm publish is needed to ship this to the pixelvault-cli package (release decision).

🤖 Generated with Claude Code

facundofarias and others added 2 commits July 7, 2026 17:16
… transformed)

The CLI could upload/list/delete but had no way to RETRIEVE an image's bytes.
Adds `pixelvault get <id>`:

- prints the CDN URL to stdout (agent-friendly, mirrors `list`)
- `--json` → full metadata
- `-o/--output <file>` → download the image to disk
- `-t/--transform "<params>"` → apply transform params (resize/format/
  segment/effects/tile) to the URL or downloaded variant, e.g.
  `get img_x -o cut.png -t "segment=foreground"`

Output contract preserved: URL to stdout, human messages to stderr. `applyTransform`
tolerates a leading ?/&. Tests: applyTransform + metadata fetch (16 total). README
+ command table updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Council (Claude + Codex) findings fixed:
- applyTransform now trims + reserializes params via URLSearchParams, so reserved
  chars in values are percent-encoded — `-t "background=#ffaa00"` previously sent
  `background=` (the `#` was parsed as a URL fragment). Also fixes whitespace-only
  `-t "   "`.
- encodeURIComponent(args.id) — a raw id like `../whoami` no longer manipulates the
  request path.
- --json is now honored in download mode (was silently overridden by -o) — emits
  metadata + transformed_url + output.
- Refuse to write a 0-byte download; wrap writeFileSync failures in CliError
  (friendly message instead of a raw fs error).
- Docs: standardize the tile example on img_logo.png; note that -t encodes for you.

+2 tests (hex encoding, folder-tile encoding); 18 total. typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@facundofarias

Copy link
Copy Markdown
Member Author

Review Council Report

Reviewers: Claude + Codex (Gemini skipped: GOOGLE_CLOUD_PROJECT auth gap; Perplexity: no key). 2 reviewers meets council minimum.

Findings fixed

# Severity Finding Fix
1 Important -t "background=#ffaa00" → server got background= (the # parsed as a URL fragment) applyTransform reserializes via URLSearchParams (encodes #///commas); also trims whitespace-only input
2 Important Image id interpolated raw → get '../whoami' hits /v1/whoami encodeURIComponent(args.id)
3 Important -o silently overrode --json (bare URL where JSON expected) --json now honored in download mode (emits metadata + transformed_url + output)
4 Important/Sugg. 0-byte/partial download reported "Saved"; writeFileSync errors raw Refuse 0-byte writes; wrap write failures in CliError
5 Suggestion tile example inconsistency (logo.png vs img_logo.png) Standardized on img_logo.png across help + README

Verified, not changed

Claude flagged the skill's size/fit preset values as unverifiable — cross-checked against the serve-worker (s=256/m=640/l=1280/social=1200×630, scale-down default): accurate.

What both praised

Correct stdout/stderr contract; raw fetch+arrayBuffer for binary (not apiRequest's .json()); no double-wrapped errors; applyTransform pure + tested.

+2 tests (18 total), typecheck clean. No direct injection/SSRF (CDN host is server-controlled).

🤖 Review Council (Claude · Codex)

@facundofarias
facundofarias merged commit 476200e into main Jul 7, 2026
2 checks passed
@facundofarias
facundofarias deleted the feat/get-download-command branch July 7, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant