A collection of utility functions for poster and graphic design calculations
npm install poster-design-utilsA collection of utility functions for poster and graphic design calculations.
Create stunning AI-powered posters at poster.sh
``bash`
npm install poster-design-utils
- 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
`javascript
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 }
`
- 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)$3
- instagram_square - 1080 × 1080
- instagram_portrait - 1080 × 1350
- instagram_story - 1080 × 1920
- facebook_post - 1200 × 630
- twitter_post - 1200 × 675
- youtube_thumbnail - 1280 × 720
- linkedin_post - 1200 × 627API Reference
$3
- mmToPixels(mm, dpi) - Convert millimeters to pixels
- pixelsToMm(pixels, dpi) - Convert pixels to millimeters
- inchesToPixels(inches, dpi) - Convert inches to pixels
- pixelsToInches(pixels, dpi) - Convert pixels to inches$3
- getPosterDimensions(size, dpi, orientation) - Get dimensions for a paper size$3
- hexToRgb(hex) - Convert HEX to RGB
- rgbToHex(r, g, b) - Convert RGB to HEX
- rgbToCmyk(r, g, b) - Convert RGB to CMYK (for print)$3
- getAspectRatio(width, height) - Calculate aspect ratio
- estimateFileSize(width, height, bitDepth, compressionRatio) - Estimate file size
- getRecommendedDpi(useCase)` - Get recommended DPI for use case- poster.sh - AI Poster Generator
- Create stunning posters with AI in seconds
MIT