Skip to content

Graphics

graphics : object

PostalPoint uses the Jimp library version 1.6 for creating and manipulating images and shipping labels.

Kind: global namespace

graphics.Jimp() ⇒ Jimp

The JavaScript Image Manipulation Program.

Kind: static method of graphics
Example

const {Jimp} = global.apis.graphics.Jimp();

graphics.loadFont(filename) ⇒ Promise

Replacement for Jimp's loadFont function, which gets very confused about our JS environment and ends up crashing everything.

Kind: static method of graphics

Param Type
filename string

graphics.pdfToImage(buffer, width, height, [autoRotate], [outputPageCount]) ⇒ Promise.<Array>

Convert a PDF to an array of images with the specified width and height. Pages that aren't the same ratio as the specified width and height will be centered on the image.

Kind: static method of graphics
Returns: Promise.<Array> - Jimp image array, one image per page

Param Type Default Description
buffer Buffer PDF data as Buffer
width Number Desired output width in pixels
height Number Desired output height in pixels
[autoRotate] Boolean true If true, images will be rotated to best fit the desired dimensions.
[outputPageCount] Number -1 Only process the first N pages, or all if -1.

graphics.zplToImage(zplData, [widthMM], [heightMM], [dpmm]) ⇒ Promise.<Array>

Convert a ZPL string to an array of images with the specified width and height. Supports ZPL data containing multiple labels; each label is rendered as its own image.

Kind: static method of graphics
Returns: Promise.<Array> - Jimp image array, one image per label.

Param Type Default Description
zplData String ZPL label data
[widthMM] Number 102 Label width in millimeters.
[heightMM] Number 152 Label height in millimeters.
[dpmm] Number 8 Dots per millimeter. 8 is 200/203 DPI, 12 is 300 DPI. Supports passing 200, 203, or 300 as well; the correct DPMM value (8 or 12) will be used.