Skip to content

Node.js helper functions to convert heropatterns to JPEGs, PNGs, SVGs, and ZIPs

License

Notifications You must be signed in to change notification settings

jlarmstrongiv/heropatterns-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heropatterns Helper

Node.js helper functions to convert heropatterns to JPEGs, PNGs, SVGs, and ZIPs

Getting Started

Installation

Install with NPM.

npm install heropatterns-helper sharp

Install with Yarn.

yarn add heropatterns-helper sharp

Please note that Sharp.js is a peer dependency for toJpeg, toPng, and toZip.

Setup and Usage

Import the library

const heropatterns = require('heropatterns-helper');

const {
  toJpeg,
  toPng,
  toSvg,
  toZip,
  getMetadata,
  FileType,
} = require('heropatterns-helper');

Helper functions

// returns object { width, height, backgroundColor, foregroundColor, svg, }
getMetadata(cssString);
// returns buffer with jpeg
toJpeg(heroPatternSvg);
// returns buffer with png
toPng(heroPatternSvg);
// returns buffer with svg
toSvg(heroPatternSvg);
// The FileType as imported above
export const FileType = {
  JPEG: 'JPEG',
  PNG: 'PNG',
  SVG: 'SVG',
  ZIP: 'ZIP',
};

// if you have already created file buffers
// the zip function can reuse them
const files = {
  [FileType.JPEG]: await toJpeg(heroPatternSvg),
};
// returns buffer with zip
toZip(heroPatternSvg, files, fileName, licenseText);

License

Heropatterns Helper Code: MIT (see license.md)

About

Node.js helper functions to convert heropatterns to JPEGs, PNGs, SVGs, and ZIPs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published