
text2image
0 Popularity
0% Service Level
180042ms Latency
N/A Test
API Overview
text2image
API that takes a string and converts it to an image of the text like in an ebook. Returns image as an array buffer.
NOTE: This API does not create AI art. It simply puts text on the image with the style you specify.
Routes
/api/get-pages
: returns the total number of pages given the data sent in the request./api/converter
: returns a JSON object with the following structure:
{
"files": [
{
"type": "png or jpeg or pdf",
"data": {
"image buffer data",
},
},
],
}
- To save the data as an image, you can create an image from the buffer:
const responseData = JSON.parse(response.data)
for (let image of responseData.files) {
return Buffer.from(image)
}
API that takes a string and converts it to an image of the text like in an ebook. Returns image as an array buffer.
Required Queries
- fileType: "png" or "jpeg"
- textType: "plainText" or "lz-string"
- If necessary, you can use lz encoding (ex.
lz-string
npm library) to encode text to make it shorter.
- If necessary, you can use lz encoding (ex.
- text: string or lz-encoded string
Optional Parameters
Note: numerical values must be numbers and not letters. For example, type "30", not "thirty".
- width: number in pixels
- height: number in pixels
- padding: number in pixels
- fontFamily: css font-family element
- Most standard system fonts should work. Others may not render correctly. I plan on adding support for more fonts in the future.
- Japanese text using the Hina Micho font is supported by default.
- fontSize: number in pixels
- backgroundColor: css color property
- ex.
#0092d2
ortomato
- ex.
- textColor: css color property
- pages: number
- specifies max number of pages. If
pages
is specified, the converter will convert as many pages it needs but will not return more than the number specified. - the API will calculate the necessary number of images by default.
- This does not make the app squeeze the text to fit it in a certain number of pages. If 2 pages are specified, it will produce the first two pages and then not send any more.
- specifies max number of pages. If
Default Option Values
- width: '800',
- height: '800',
- padding: '0',
- fontFamily: 'Times New Roman, Hina Mincho',
- fontSize: '16',
- backgroundColor: '#ffffff',
- textColor: '#000000',