Installations
npm install twitter-card-image
Developer Guide
Typescript
No
Module System
CommonJS
Score
59.7
Supply Chain
97.6
Quality
72
Maintenance
100
Vulnerability
97.9
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (88.71%)
HTML (11.29%)
Developer
raresportan
Download Statistics
Total Downloads
1,757
Last Day
1
Last Week
12
Last Month
33
Last Year
152
GitHub Statistics
24 Commits
2 Watching
9 Branches
1 Contributors
Bundle Size
23.78 kB
Minified
7.97 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.9
Package Id
twitter-card-image@1.0.9
Unpacked Size
15.01 kB
Size
4.98 kB
File Count
7
Total Downloads
Cumulative downloads
Total Downloads
1,757
Last day
0%
1
Compared to previous day
Last week
20%
12
Compared to previous week
Last month
1,550%
33
Compared to previous month
Last year
-34.8%
152
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
4
node-twitter-card-image
A small library that creates Twitter card images using node-canvas
.
It uses tinypng
API to optimize the image if you provide an API key
Install
npm install twitter-card-image --save-dev
Quick Example
Creates a twitter card image, 1280x669, using a template image. Renders two texts using the Robot font. The top border is rendered with a gradient.
1const makeCard = require('twitter-card-image'); 2 3makeCard({ 4 width: 1280, 5 height: 669, 6 tinypngApiKey: '', 7 output: './card.png', 8 templateImage: './twitter-card-template.png', 9 fonts: [ 10 { 11 file: 'Roboto-Bold.ttf', 12 family: 'Roboto' 13 } 14 ], 15 texts: [ 16 { 17 text: 'Will Grizzly Bears Survive Being Hunted?', 18 font: '64px "Roboto"', 19 x: 500, 20 y: 669 / 2, 21 color: '#222', 22 maxWidth: 700, 23 lineHeight: 64 24 }, 25 { 26 text: 'savethebear.com', 27 font: '26pt "Roboto"', 28 x: 'center', 29 y: 669 - 36, 30 color: '#444', 31 } 32 ], 33 backgroundColor: '#fff', 34 borderTop: { 35 gradient: [ 36 { 37 color: '#e66465', 38 stop: 0 39 }, 40 { 41 color: '#9198e5', 42 stop: 50 43 }, 44 ], 45 width: 20 46 } 47}); 48
Options
The following options are available:
width
The image width. Default 1280.
1width: 1280
height
The image height. Default 669.
1height: 669
tinypngApiKey
Your Tinypng API Key. You can get one for free here. Use this if you want to compress your images. Highly recommended.
output
The image name. Default test.jpeg It must include the extension: .png, .jpg or .jpeg.
1output: './awesome.png'
backgroundColor
The backround color to use. It will fill the entire image. All HTML color values are accepted.
1backgroundColor: '#444'
templateImage
The path to the image to use as a template. Default none. This should be the static part on all cards, like logo, patterns, etc. It will be drawn from the top left position of the image.
1templateImage: './twitter-card-template.png'
Example:
fonts
The fonts to use for the texts rendered on the card. Each font file must available locally on the machine.
For each font you specify the file and the family. The family you'll set later for texts.
Example:
1fonts: [ 2 file: 'Roboto-Bold.ttf', 3 family: 'Roboto' 4]
texts
The texts to render on card. For each text entry the following parameters can be set:
- text: string, the actual text to render e.g. 'Hello,world!'
- font: string, the font size and family. e.g. '30pt "Open Sans"'
- x: horizontal start drawing position as number or spacial value 'center' (to put in on the horizontal middle on the image)
- y: vertical start drawing position as number or spacial value 'center' (to put in on the vertical middle on the image)
- maxWidth: the text maximum width, number. If the text si bigger it will be split and rendered on multiple lines.
- lineHeight: the text line height, number.
Example:
1texts: [ 2 { 3 text: 'Will Grizzly Bears Survive Being Hunted?', 4 font: '64px "Roboto"', 5 x: 500, 6 y: 669 / 2, 7 color: '#222', 8 maxWidth: 700, 9 lineHeight: 64 10 }, 11 { 12 text: 'savethebear.com', 13 font: '26pt "Roboto"', 14 x: 'center', 15 y: 669 - 36, 16 color: '#444', 17 } 18],
borderTop
The settings for the top border. You can provide either a color or a gradient and a width. It is rendered before all other borders.
1borderTop: { 2 color: '#ffc100', 3 width: 20 4}
Or using a gradient:
1borderTop: { 2 gradient: [ 3 { 4 color: '#e66465', 5 stop: 0 6 }, 7 { 8 color: '#9198e5', 9 stop: 50 10 }, 11 ], 12 width: 20 13}
borderRight
The settings for the right border. You can provide either a color or a gradient and a width. It is rendered after the top border but before the other borders, so it renders over the top border.
borderBottom
The settings for the bottom border. You can provide either a color or a gradient and a width. It is rendered after the top and right border but before the left border, so it renders over the right border.
borderLeft
The settings for the left border. You can provide either a color or a gradient and a width. It is rendered after all other borders, so it renders over the top and bottom borders.
roundedBorder
To render a rounded-corners border use this option with the following parameters:
- color or gradient.
- radius: the rounder-corner radius, number
- width: the border width, number.
1roundedBorder: { 2 color: 'red', 3 gradient: [ 4 { 5 color: '#e66465', 6 stop: 0 7 }, 8 { 9 color: '#9198e5', 10 stop: 50 11 }, 12 ], 13 radius: 20, 14 width: 30 15}
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1
- Info: no jobLevel write permissions found
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/raresportan/node-twitter-card-image/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/raresportan/node-twitter-card-image/npm-publish.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/raresportan/node-twitter-card-image/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/raresportan/node-twitter-card-image/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/raresportan/node-twitter-card-image/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/raresportan/node-twitter-card-image/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/raresportan/node-twitter-card-image/npm-publish.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Reason
16 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.5
/10
Last Scanned on 2025-01-06
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to twitter-card-image
wasm-twitter-card
A humble pre-release library that does one thing only: provides a `generate_text` function for creating a twitter card-size image (630 x 1200 px) returned as a Uint8Array of pixels.
gatsby-remark-twitter-cards
Gatsby Remark plugin for generating Twitter Open Graph cards
canvafy
Make configurable canvas easily with Canvafy
wasm-layout-text
provides a `generate_text` function for creating a twitter card-size image (630 x 1200 px) returned as a Uint8Array of pixels.