
In this post, we'll teach you how to create a thubnail generator using node.js and Pictify API. A thumbnail generator is a tool that allows you to create custom thumbnails for your videos, blog posts, or social media posts. By creating custom thumbnails, you can grab your audience's attention and entice them to click on your content.
Creating custom thumbnails has several benefits:
Before we get started, make sure you have the following prerequisites:
axios package by running the following command in your terminal: cheerio package by running the following command in your terminal: ejs package by running the following command in your terminal: First, create a new file called generateThumbnail.js and add the following code:
Replace YOUR_API_KEY with your actual API key.
Next, create a new file (e.g., blogPost.html) for which you want to generate a thumbnail. This file will be used as the input for the thumbnail generator.
Example blogPost.html:
The blogPost.html file could be any HTML file for which you want to generate a thumbnail. This file should contain the content and images you want to include in the thumbnail. This could also be a url of a webpage.
Now, we will create a ejs template for the thumbnail. Add the following code to thumbnailTemplate.ejs:
EJS is a simple templating language that lets you generate HTML markup with plain JavaScript. In this template, we're using EJS to dynamically insert the hero image and title from the blog post.
Now we need to generate the HTML content for the thumbnail. Add the following code to generateThumbnail.js:
If you are using a url of a webpage, you can use axios to fetch the html content of the webpage as shown below:
Make sure you use the correct selectors to extract the hero image and title from the HTML content.
The generateThumbnailHTML function reads the content of the blogPost.html file, extracts the hero image and title using Cheerio, and renders the thumbnail template using EJS.
Finally, we'll use the Pictify API to generate the thumbnail image. Add the following code to generateThumbnail.js:
This code sends a POST request to the Pictify API with the generated HTML content and retrieves the URL of the generated thumbnail image.
Finally, the complete code for generateThumbnail.js should look like this:
Update the main function with the URL of the blog post or webpage for which you want to generate a thumbnail. Then run the script by executing the following command in your terminal:
The script will generate a URL which will be the thumbnail image. You can download the image by visiting the URL in your browser. The thumbnail for this example will look like this:

You can customize the thumbnail template and HTML content to suit your needs. Experiment with different styles and content to create engaging thumbnails for your content.
Hope this helps! If you have any questions or need further assistance, feel free to reach out to us. We're here to help!
Happy thumbnailing!