File

File Manipulation

Trelae lets you transform uploaded files by queuing one or more operations—then applying them all at once with .save().

Supported types:

  • Images (image/*) — freely chain many operations (see below), then .save().
  • PDFs (application/pdf) — only compress() is allowed in a chain; for transformations, use pdfToImages() / pdfToMarkdown().
  • Videos (video/*) — chain rich video operations (format, trim, crop, speed, overlays, filters, audio tools). Save runs async by default; poll via getVideoStatus().

Supported Operations

Images

  • resize / crop
  • compress / convert / rotate / flip
  • border / background
  • grayscale, blur, sharpen, tint, adjust
  • threshold, trim
  • composite (overlay another file/image)
  • addText
  • removeBackground

PDFs

  • compress
  • pdfToImages — convert selected pages to JPEG/PNG images
  • pdfToMarkdown (OCR) — extract structured Markdown and images

Videos

  • changeFormat (container/codecs/CRF/preset)
  • trim, scale, rotateFlip, removeAudio, speed
  • crop, muteSegment, fade (visual)
  • addText (timed overlay), addBorder
  • reverse, audioFade, motionBlur
  • grayscale, colorEQ, hueRotate, boxBlur, sharpen, volume

How It Works

  1. Create a file handle: const file = trelae.file('FILE_ID')
  2. Chain operations:
    • Images: file.resize({ width: 400 }).rotate(90)...
    • Videos: file.trimVideo({ start: 2, duration: 6 }).addTextVideo({...})...
  3. Apply everything with .save()
    • Images/PDFs: returns { success: true, message }
    • Videos: returns { type: 'video', status, operationId, file? }
  4. For PDFs, use dedicated methods for page/image extraction or OCR

Next Steps