npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

orator-conversion

v1.0.7

Published

File format conversion endpoints for Orator service servers.

Readme

Orator File Translation

File format conversion endpoints for Orator service servers

Orator File Translation provides a simple way to add file format conversion endpoints to an Orator web server. It ships with built-in image converters (JPG to PNG, PNG to JPG), PDF page extraction (PDF to PNG/JPG via pdftoppm), and supports registering custom converters for any file format. All routes are versioned.

Features

  • Image Conversion - Convert between JPG and PNG formats via HTTP POST endpoints
  • PDF Page Extraction - Extract individual pages from PDFs as PNG or JPEG images
  • Versioned Routes - All endpoints include a configurable version segment
  • Extensible - Register custom converters for any file format via addConverter()
  • Configurable - Settings via constructor options or Fable settings
  • Size Limits - Configurable maximum file size to prevent abuse
  • Fable Service Provider - Registers as a standard Fable service

Quick Start

const libFable = require('fable');
const libOrator = require('orator');
const libOratorServiceServerRestify = require('orator-serviceserver-restify');
const libOratorFileTranslation = require('orator-conversion');

const _Fable = new libFable({
	Product: 'MyConversionServer',
	APIServerPort: 8080
});

// Set up Orator with Restify
_Fable.serviceManager.addServiceType('Orator', libOrator);
_Fable.serviceManager.addServiceType('OratorServiceServer', libOratorServiceServerRestify);
_Fable.serviceManager.instantiateServiceProvider('Orator');
_Fable.serviceManager.instantiateServiceProvider('OratorServiceServer');

// Set up file translation
_Fable.serviceManager.addServiceType('OratorFileTranslation', libOratorFileTranslation);
_Fable.serviceManager.instantiateServiceProvider('OratorFileTranslation');

// Initialize and start
_Fable.Orator.startService(
	() =>
	{
		_Fable.OratorFileTranslation.connectRoutes();
		// POST http://localhost:8080/conversion/1.0/image/jpg-to-png
		// POST http://localhost:8080/conversion/1.0/image/png-to-jpg
		// POST http://localhost:8080/conversion/1.0/pdf-to-page-png/:Page
		// POST http://localhost:8080/conversion/1.0/pdf-to-page-jpg/:Page
	});

Installation

npm install orator-conversion

System Dependencies

PDF page extraction requires pdftoppm (part of the poppler-utils package):

# macOS
brew install poppler

# Debian/Ubuntu
apt-get install poppler-utils

Configuration

| Setting | Type | Default | Description | |---------|------|---------|-------------| | RoutePrefix | string | "/conversion" | URL prefix for conversion endpoints | | Version | string | "1.0" | Version segment in route URLs | | LogLevel | number | 0 | Logging verbosity (higher = more output) | | MaxFileSize | number | 10485760 | Maximum upload size in bytes (default 10MB) | | PdftkPath | string | "pdftk" | Path to the pdftk binary | | PdftoppmPath | string | "pdftoppm" | Path to the pdftoppm binary |

Settings can also be provided via Fable settings:

| Fable Setting | Maps To | |---------------|---------| | OratorFileTranslationRoutePrefix | RoutePrefix | | OratorFileTranslationVersion | Version | | OratorFileTranslationLogLevel | LogLevel | | OratorFileTranslationMaxFileSize | MaxFileSize | | OratorFileTranslationPdftkPath | PdftkPath | | OratorFileTranslationPdftoppmPath | PdftoppmPath |

API

connectRoutes()

Register POST endpoints on the Orator service server for each registered converter. Routes are versioned: {RoutePrefix}/{Version}/{converterPath}. Call this after Orator has been started.

_Fable.OratorFileTranslation.connectRoutes();

addConverter(pPath, fConverter)

Register a custom converter. The path becomes part of the endpoint URL ({RoutePrefix}/{Version}/{pPath}). The converter function receives the input buffer, the request object, and a callback.

_Fable.OratorFileTranslation.addConverter('document/csv-to-json',
	(pInputBuffer, pRequest, fCallback) =>
	{
		let tmpCSV = pInputBuffer.toString('utf8');
		let tmpJSON = convertCSVToJSON(tmpCSV);
		return fCallback(null, Buffer.from(JSON.stringify(tmpJSON)), 'application/json');
	});

extractPdfPage(pPdfBuffer, pPageNumber, fCallback)

Extract a single page from a PDF buffer using pdftk, returning the single-page PDF as a buffer.

renderPdfPageToImage(pPdfBuffer, pPageNumber, pFormat, fCallback)

Render a specific page of a PDF to an image buffer using pdftoppm. The pFormat parameter can be 'png' or 'jpeg'.

Endpoints

All endpoints are versioned. Conversion endpoints accept raw binary data via POST and return the converted file:

# Convert JPG to PNG
curl -X POST --data-binary @photo.jpg \
	-H "Content-Type: application/octet-stream" \
	http://localhost:8080/conversion/1.0/image/jpg-to-png \
	-o photo.png

# Convert PNG to JPG
curl -X POST --data-binary @image.png \
	-H "Content-Type: application/octet-stream" \
	http://localhost:8080/conversion/1.0/image/png-to-jpg \
	-o image.jpg

# Extract page 1 from a PDF as PNG
curl -X POST --data-binary @document.pdf \
	-H "Content-Type: application/octet-stream" \
	http://localhost:8080/conversion/1.0/pdf-to-page-png/1 \
	-o page1.png

# Extract page 3 from a PDF as JPEG
curl -X POST --data-binary @document.pdf \
	-H "Content-Type: application/octet-stream" \
	http://localhost:8080/conversion/1.0/pdf-to-page-jpg/3 \
	-o page3.jpg

Documentation

Full documentation is available in the docs folder, or served locally:

npx docsify-cli serve docs

Related Packages

License

MIT

Contributing

Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the Retold Contributing Guide.