DEV Community

Yatin Davra
Yatin Davra

Posted on

How to Create Multi-Page TIFF Files in Node.js (Without ImageMagick)

If you've ever tried to create a multi-page TIFF in Node.js, you know the pain. Most solutions require ImageMagick as a system dependency, which is a headache in Docker, serverless environments, or CI pipelines. Others wrap native binaries with brittle child_processcalls.

I ran into this exact problem while building a document processing pipeline — I needed to merge multiple scanned images into a single multi-page TIFF programmatically, with no external system dependencies.

After digging through the options, I ended up writing a pure Node.js solution and published it as an npm package: multi-page-tiff.

The Problem

Multi-page TIFF files store multiple images as linked Image File Directories (IFDs) inside a single .tiff file. Creating one correctly means writing the TIFF binary structure yourself — most image libraries only handle reading, not writing multi-page TIFFs.

Common workarounds people try:

  • ImageMagick via child_process— works but requires ImageMagick installed, breaks in serverless
  • sharp — great library but doesn't support writing multi-page TIFFs
  • tiff-multipage — last published 3 years ago, minimal maintenance
  • tiff-to-png — converts TIFF to PNG, not the other way

The Solution

npm install multi-page-tiff

const { createMultiPageTiff } = require('multi-page-tiff');
const fs = require('fs');

const images = [
  fs.readFileSync('./page1.png'),
  fs.readFileSync('./page2.png'),
  fs.readFileSync('./page3.png'),
];

const tiffBuffer = await createMultiPageTiff(images);
fs.writeFileSync('./output.tiff', tiffBuffer);
Enter fullscreen mode Exit fullscreen mode

That's it. No native binaries, no system dependencies. Works on AWS Lambda, Vercel, Docker, Windows — anywhere Node.js runs.

Use Cases
Multi-page TIFFs are common in:

  • Fax systems — fax files are almost always multi-page TIFFs
  • Document scanning — scanners output multi-page TIFFs
  • Medical imaging — DICOM-adjacent workflows often use TIFF
  • Legal/archival — PDF alternatives for scanned documents
  • Insurance and banking — document submission pipelines

Why Not Just Use PDF?
TIFF is lossless, supports higher bit depths (16-bit, 32-bit), and is required in many enterprise, government, and medical workflows where PDF is not accepted. If your system specification says TIFF, there's usually no substitute.

Links

If you've been fighting with multi-page TIFF generation in Node.js, give it a try and let me know in the comments if you run into any issues.

Top comments (0)