Pollinations Watermark is a Node.js application that generates watermarked images using the Express framework, Axios for making HTTP requests, and Sharp for image processing. The application downloads an image from a given URL, crops it, and adds a watermark to the resulting image. This documentation provides an overview of the application's code structure and usage.
-
Clone the repository:
git clone https://github.com/sachnun/pollinations_watermark.git
-
Navigate to the project directory:
cd pollinations_watermark
-
Install the dependencies:
npm install
-
Start the application:
npm start
-
The server will start running on port 3000. You can access the root endpoint at
http://localhost:3000/
. -
To generate a watermarked image, make a GET request to the
/image/:parameter
endpoint, where:parameter
represents the desired image parameter. The application will download the image from the Pollinations AI website, crop it, add a watermark, and return the resulting image.Example request:
GET /image/parameter-value
Replace
parameter-value
with the desired image parameter. -
The resulting watermarked image will be returned as the response.
The application code is structured as follows:
- The required modules (
express
,axios
, andsharp
) are imported at the beginning. - An instance of the Express application is created and assigned to the
app
variable. - The port number
3000
is assigned to theport
variable. - The root endpoint
/
is defined to respond with a JSON message indicating the image generation. - The
/image/:parameter
endpoint is defined to handle image generation requests. It downloads the image from the specified Pollinations AI URL, crops it, adds a watermark, and returns the resulting image. - The server is started by listening on the specified port.
The application relies on the following dependencies:
- Express: A minimal and flexible Node.js web application framework.
- Axios: A promise-based HTTP client for the browser and Node.js.
- Sharp: A high-performance Node.js image processing library.
These dependencies are automatically installed when running npm install
.
The Pollinations Watermark application allows you to generate watermarked images by downloading an image from a specified URL, cropping it, and adding a watermark. By following the installation and usage instructions, you can easily run the application and integrate it into your own projects.