1.2.0 • Published 4 years ago

images-pptx v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

images-pptx

A simple and blazing-fast javascript library for creating PPTX presentation from list of images

If you have a set of raster picture files (for example, after converting PDF to JPG's) and you want to nicely wrap them into PowerPoint presentation–images-pptx is everything that you need.

Use it with pure Node.js or TypeScript: library is written on TS and has all typings.

Currently works:

Node.jsBrowserCLI
YesWIPYes

Installation

Via npm:

npm install --save images-pptx

Usage

Add it to your project:

// JavaScript
const ImagesPptx = require('images-pptx')
// TypeScript
import * as ImagesPptx from 'images-pptx'
// or, for TypeScript
import { createPptx } from 'images-pptx';

After that, you can use it like this:

await ImagesPptx.createPptx(options)

Options are:

OptionDescription
picturesArray of full paths to images (array of string) or single string to the directory where image files are placed
saveToPath to the directory (string) where .pptx file will be created
pptxFileNameName of .pptx file (string) (default is "presentation.pptx"
extensionExtension of pictures (string, default: "jpg") which will be used in pptx (f.e. "jpg")
nativeBoolean (default is false). Forces images-pptx use native OS commands, such as cp or rm on Mac and Linux instead of Node-based solutions. This solution can be a bit faster. WARNING to Windows users: this functionality was not tested correctly on Windows yet.
metaMeta fields for presentation (see below)

Example usage:

await ImagesPptx.createPptx({
  pictures: '/Users/username/Pictures',
  saveTo: '/Users/username/Presentation',
  pptxFileName: 'Our great party.pptx',
  extension: 'png',
  native: true,
  meta: {
    author: 'Lyoha Plotinka',
    title: 'Our great party!',
    revision: 2,
    createdAt: '2020-09-08T10:24:09.658Z'
  }
})

This will generate file /Users/username/Presentation/Our great party.pptx with all the .png files from /Users/username/Pictures.

For every key in meta objects there are default values:

  • Images-pptx presentation from title;
  • Images-pptx for author;
  • 1 for revision;
  • Output from new Date().toISOString() for createdAt

CLI usage

You can use images-pptx as command-line app. Install it globally or call it from node_modules folder. For example:

npm install -g images-pptx
# after installing
images-pptx --help
# ...all usage options printed next

How fast is it?

All test were made on MacOS, using console.time and console.timeEnd

OptionsResult
3 pictures, ~8.5mb total; native: false; directory with extension as a path453.053ms
3 pictures, ~8.5mb total; native: true; directory with extension as a path335.393ms
27 pictures, ~49mb total; native: false; directory with extension as a path2518.479ms
27 pictures, ~49mb total; native: true; directory with extension as a path1893.986ms
3 pictures, ~8.5mb total; native: false; array of direct paths323.845ms

TODO

  1. Browser version of images-pptx
  2. Proportional resizing of pictures

Found a bug?

Feel free to contribute, create an issue or contact me directly. All my contacts are availabe on my website

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago