poster-design-utils
v1.0.0
Published
A collection of utility functions for poster and graphic design calculations
Maintainers
Readme
poster-design-utils
A collection of utility functions for poster and graphic design calculations.
Create stunning AI-powered posters at poster.sh
Installation
npm install poster-design-utilsFeatures
- Paper size constants (ISO A-series, US sizes, social media dimensions)
- Unit conversions (mm, inches, pixels)
- Color conversions (HEX, RGB, CMYK)
- DPI calculations for print and web
- Aspect ratio calculations
- File size estimation
Usage
const posterUtils = require('poster-design-utils');
// Get poster dimensions in pixels
const a3Poster = posterUtils.getPosterDimensions('a3', 300, 'portrait');
console.log(a3Poster);
// { width: 3508, height: 4961, name: 'A3', orientation: 'portrait' }
// Get Instagram story dimensions
const story = posterUtils.getPosterDimensions('instagram_story');
console.log(story);
// { width: 1080, height: 1920, name: 'Instagram Story', orientation: 'portrait' }
// Convert mm to pixels
const pixels = posterUtils.mmToPixels(210, 300); // A4 width at 300 DPI
console.log(pixels); // 2480
// Color conversions
const rgb = posterUtils.hexToRgb('#ff5733');
console.log(rgb); // { r: 255, g: 87, b: 51 }
const cmyk = posterUtils.rgbToCmyk(255, 87, 51);
console.log(cmyk); // { c: 0, m: 66, y: 80, k: 0 }
// Get aspect ratio
const ratio = posterUtils.getAspectRatio(1920, 1080);
console.log(ratio); // '16:9'
// Estimate file size
const fileSize = posterUtils.estimateFileSize(3508, 4961, 24, 0.1);
console.log(fileSize); // { bytes: 2088670, kb: 2040, mb: 1.99 }Available Paper Sizes
Print Sizes (mm)
a0- A0 (841 × 1189 mm)a1- A1 (594 × 841 mm)a2- A2 (420 × 594 mm)a3- A3 (297 × 420 mm)a4- A4 (210 × 297 mm)a5- A5 (148 × 210 mm)a6- A6 (105 × 148 mm)letter- US Letter (216 × 279 mm)legal- US Legal (216 × 356 mm)tabloid- Tabloid (279 × 432 mm)
Social Media Sizes (pixels)
instagram_square- 1080 × 1080instagram_portrait- 1080 × 1350instagram_story- 1080 × 1920facebook_post- 1200 × 630twitter_post- 1200 × 675youtube_thumbnail- 1280 × 720linkedin_post- 1200 × 627
API Reference
Unit Conversion
mmToPixels(mm, dpi)- Convert millimeters to pixelspixelsToMm(pixels, dpi)- Convert pixels to millimetersinchesToPixels(inches, dpi)- Convert inches to pixelspixelsToInches(pixels, dpi)- Convert pixels to inches
Poster Dimensions
getPosterDimensions(size, dpi, orientation)- Get dimensions for a paper size
Color Conversion
hexToRgb(hex)- Convert HEX to RGBrgbToHex(r, g, b)- Convert RGB to HEXrgbToCmyk(r, g, b)- Convert RGB to CMYK (for print)
Utilities
getAspectRatio(width, height)- Calculate aspect ratioestimateFileSize(width, height, bitDepth, compressionRatio)- Estimate file sizegetRecommendedDpi(useCase)- Get recommended DPI for use case
Related
- poster.sh - AI Poster Generator
- Create stunning posters with AI in seconds
License
MIT
