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) — onlycompress()is allowed in a chain; for transformations, usepdfToImages()/pdfToMarkdown(). - Videos (
video/*) — chain rich video operations (format, trim, crop, speed, overlays, filters, audio tools). Save runs async by default; poll viagetVideoStatus().
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
- Create a file handle:
const file = trelae.file('FILE_ID') - Chain operations:
- Images:
file.resize({ width: 400 }).rotate(90)... - Videos:
file.trimVideo({ start: 2, duration: 6 }).addTextVideo({...})...
- Images:
- Apply everything with
.save()- Images/PDFs: returns
{ success: true, message } - Videos: returns
{ type: 'video', status, operationId, file? }
- Images/PDFs: returns
- For PDFs, use dedicated methods for page/image extraction or OCR
