Generate Social Media Preview Images from templates.
npm install shareimage/imagesh
pip install ShareImage
`
$3
To Install ShareImage in Node.js with NPM Run:
`sh
npm i shareimage --save
`
Or, with Yarn:
`sh
yarn add shareimage
`
Usage
Using ShareImage is a bit different across Languages.
$3
Use the Following Code to Generate a Image and print it's URL in Python:
`py
from ShareImage import ShareImageimage = ShareImage(
title = "My Test Image",
cloudName = "myCloud",
imagePublicId = "myFolder/myImage"
)
print(image)
`
$3
Use the Following Code to Generate a Image and output it's URL in Node.js (ES6):
`js
import * as ShareImage from 'shareimage';const image = await ShareImage.generateImage(
"/path/to/image.png",
"My awesome title",
{ type: "datauri" }
)
console.log(image)
`Parameters
There are only 2 Required Parameters and several optional params.
$3
| Parameter | Type | Description |
| :-------------: | :----: | :-------------------------------------------: |
| src | String | URL/Buffer of the Image |
| title | String | Title of the Image |
$3
#### output Object (3rd parameter)
| Parameter | Type | Default | Description |
| :-------: | :---: | :-----: | :-----------------------------------------------------------------------------------------------------------------------------------------------------: |
| type | String | base64 | The format of the output. Can be buffer, datauri, base64, or file (Save the file in FS). This option is necessary but comes with default value. |
| options | Object | {} | This option is necessary if type is set to file. The structure of the options Object is {options: {file: {path: "/file/to/output.png"}}} |####
props Object (4th parameter)
| Parameter | Type | Default | Description |
| :------------------: | :-----: | :------------------------: | :----------------------------------------------------------------: |
| tagline | String | None | Tagline of Website or Tags of Post |
| titleFont |ShareFont| sirin-stencil | Font of Title |
| titleExtraConfig | String | '' | Extra Title Config |
| taglineExtraConfig | String | '' | Extra Config of Tagline |
| taglineFont |ShareFont| arial | Font of Tagline |
| imageWidth | Number | 1280 | Width of Image |
| imageHeight | Number | 669 | Height of Image |
| textAreaWidth | Number | 760 | Width of TextArea |
| textLeftOffset | Number | 480 | Left Offset of Text |
| titleGravity | String | south_west | Gravity of Title |
| taglineGravity | String | north_west | Gravity of Tagline |
| titleLeftOffset | Number | None | Left Offset of Title |
| taglineLeftOffset | Number | None | Left Offset of Tagline |
| titleBottomOffset | Number | 254 | Bottom Offset of Title |
| taglineTopOffset | Number | 445 | Top Offset of Tagline |
| textColor | String | 000000 | Color of Text |
| titleColor | String | None | Color of Title (If not provided textColor will be used instead |
| taglineColor | String | None | Color of Tagline (If not provided textColor will be used instead |
| titleFontSize | Number | 64 | Font Size of Title |
| taglineFontSize | Number | 48 | Font Size of Tagline |Note: If you don't provide Tagline, Parameters with
tagline` Prefix will be ignored. 