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

node-pptx-png

v1.0.0

Published

High-fidelity PPTX to PNG converter for Node.js

Readme

node-pptx-png

High-fidelity PPTX to PNG converter for Node.js.

Overview

node-pptx-png is a pure JavaScript/TypeScript library for converting PowerPoint (PPTX) presentations to high-quality PNG images. It uses native canvas rendering (via skia-canvas) for accurate slide reproduction without relying on LibreOffice, Puppeteer, or other external dependencies.

Features

  • Pure Node.js - No external dependencies like LibreOffice or headless browsers
  • High fidelity - Skia-based rendering for accurate slide reproduction
  • TypeScript - Full type definitions included
  • Configurable - Control output size, format, and quality
  • PNG optimization - Optional Sharp integration for 60-70% smaller files
  • Theme support - Proper resolution of PowerPoint theme colors and fonts
  • Rich content support:
    • Shapes with preset geometries (rectangles, chevrons, arrows, etc.)
    • Text with full styling (fonts, colors, bullets, alignment)
    • Images (embedded and linked)
    • Tables with cell formatting
    • Charts (bar, line, pie)
    • Backgrounds (solid, gradient, image)
    • Master/layout inheritance

Installation

npm install node-pptx-png

Prerequisites

This library uses skia-canvas for rendering. It should work out of the box on most systems, but you may need:

On macOS:

brew install pkg-config

On Ubuntu/Debian:

sudo apt-get install build-essential libfontconfig1-dev

Usage

Basic Usage

import { PptxImageRenderer } from 'node-pptx-png';
import * as fs from 'fs';

const renderer = new PptxImageRenderer();

// Render all slides
const result = await renderer.renderPresentation('./presentation.pptx', {
  format: 'png',
  scale: 1.0
});

for (const slide of result.slides) {
  if (slide.imageData) {
    fs.writeFileSync(`slide-${slide.slideNumber}.png`, slide.imageData);
  }
}

With Options

import { PptxImageRenderer } from 'node-pptx-png';

const renderer = new PptxImageRenderer({ logLevel: 'info' });

const result = await renderer.renderPresentation('./presentation.pptx', {
  scale: 0.5,              // Scale factor (0.5 = half size)
  format: 'png',           // Output format
  slideNumbers: [1, 2, 3], // Optional: render only specific slides
});

With PNG Optimization

For smaller file sizes, enable PNG optimization (requires sharp to be installed):

npm install sharp
import { PptxImageRenderer } from 'node-pptx-png';

const renderer = new PptxImageRenderer();

// Use the 'web' preset for maximum compression (60-70% smaller)
const result = await renderer.renderPresentation('./presentation.pptx', {
  pngOptimization: 'web'
});

// Or use other presets
const result2 = await renderer.renderPresentation('./presentation.pptx', {
  pngOptimization: 'balanced'  // ~2-3% smaller, lossless
});

// Or use custom options
const result3 = await renderer.renderPresentation('./presentation.pptx', {
  pngOptimization: {
    compressionLevel: 9,
    adaptiveFiltering: true,
    palette: true,
    colors: 128,
    quality: 80
  }
});

Rendering from Buffer

import { PptxImageRenderer } from 'node-pptx-png';
import * as fs from 'fs';

const pptxBuffer = fs.readFileSync('./presentation.pptx');
const renderer = new PptxImageRenderer();
const result = await renderer.renderPresentation(pptxBuffer);

API Reference

PptxImageRenderer

Main class for rendering presentations.

Constructor

new PptxImageRenderer(options?: { logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent' })

Methods

renderPresentation(input, options?)

Renders all slides (or specified slides) in a presentation.

  • input: Buffer | string - File path or buffer containing PPTX data
  • options: RenderOptions - Optional rendering options
  • Returns: Promise<PresentationRenderResult>
getSlideCount(input)

Gets the number of slides in a presentation.

  • input: Buffer | string - File path or buffer containing PPTX data
  • Returns: Promise<number>

RenderOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | scale | number | 1.0 | Scale factor for output size | | format | 'png' | 'png' | Output format | | slideNumbers | number[] | all | Specific slides to render (1-based) | | pngOptimization | string \| object | 'none' | PNG optimization preset or custom options |

PNG Optimization Presets

| Preset | Size Reduction | Description | |--------|----------------|-------------| | 'none' | 0% | No optimization (fastest) | | 'fast' | ~1-2% | Quick lossless compression | | 'balanced' | ~2-3% | Lossless with adaptive filtering | | 'maximum' | ~2-3% | Best lossless compression | | 'web' | 60-70% | Palette quantization (may affect photo quality) |

PngOptimizationOptions

For custom PNG optimization:

| Option | Type | Default | Description | |--------|------|---------|-------------| | compressionLevel | number | 6 | Compression level (0-9, higher = smaller) | | adaptiveFiltering | boolean | true | Use adaptive row filtering | | palette | boolean | false | Convert to indexed PNG (max 256 colors) | | colors | number | 256 | Max colors for palette mode (2-256) | | quality | number | 90 | Palette quantization quality (1-100) | | dither | number | 1.0 | Dithering strength for palette mode (0-1) |

SlideRenderResult

| Property | Type | Description | |----------|------|-------------| | slideIndex | number | Zero-based slide index | | slideNumber | number | One-based slide number | | imageData | Buffer | Rendered image data | | width | number | Image width in pixels | | height | number | Image height in pixels | | success | boolean | Whether rendering succeeded | | errorMessage | string? | Error message if failed |

PresentationRenderResult

| Property | Type | Description | |----------|------|-------------| | slides | SlideRenderResult[] | Results for each slide | | totalSlides | number | Total number of slides | | successfulSlides | number | Number of successfully rendered slides | | allSuccessful | boolean | Whether all slides rendered successfully |

Supported Features

Shapes

  • Rectangles, rounded rectangles
  • Chevrons, arrows, pentagons
  • Ellipses, circles
  • Lines and connectors
  • Custom geometries

Text

  • Font families and sizes
  • Bold, italic, underline, strikethrough
  • Text colors (solid and theme colors)
  • Bullet points and numbered lists
  • Paragraph alignment
  • Line spacing
  • Superscript/subscript

Fills

  • Solid colors
  • Theme/scheme colors (accent1-6, dk1, lt1, etc.)
  • Gradients (linear)
  • Picture fills

Tables

  • Cell backgrounds
  • Borders
  • Merged cells
  • Text formatting within cells

Charts

  • Bar/column charts
  • Line charts
  • Pie charts
  • Chart titles and legends

Other

  • Background images
  • Master slide inheritance
  • Layout inheritance
  • Placeholder resolution
  • Shape effects (shadows)

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Type check
npx tsc --noEmit

# Render a test presentation
npx ts-node scripts/render-pptx.ts ./test.pptx ./output

License

MIT