image-genv3
Version:
## Description `image-genv3` is an AI-powered image generation package that allows users to create stunning visuals based on text prompts. It simplifies the process of generating AI-driven artwork and is easy to integrate into your JavaScript or Node.js p
117 lines (83 loc) • 3.72 kB
Markdown
`image-genv3` is an AI-powered image generation package that allows users to create stunning visuals based on text prompts. It simplifies the process of generating AI-driven artwork and is easy to integrate into your JavaScript or Node.js projects.
Install the package using npm:
```sh
npm install image-genv3
```
Below is a simple example demonstrating how to use `image-genv3` to generate an image from a text prompt.
```javascript
const rexzimagine = require("image-genv3");
async function main() {
const prompt = "A futuristic cyberpunk cityscape with neon lights and flying cars.";
const result = await rexzimagine.response(prompt);
console.log(result);
}
main();
```
Below is a simple example demonstrating how to use `image-genv3` in discord bot to generate an image from a text prompt with the help of `MongoDB` (you can use any other DB or send it directly).
```javascript
const { Client, GatewayIntentBits } = require('discord.js');
const mongoose = require('mongoose');
const fs = require('fs');
const rexzimagine = require('image-genv3');
const { GridFSBucket } = require('mongodb');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
token = 'your bot token'
mongoose.connect('Your Mongo DB ', { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('Connected to MongoDB'))
.catch(err => console.error(err));
const db = mongoose.connection;
let bucket;
db.once('open', () => {
bucket = new GridFSBucket(db.db, { bucketName: 'images' });
});
client.on('messageCreate', async (message) => {
if (!message.content.startsWith('-imagine')) return;
const prompt = message.content.replace('-imagine ', '').trim();
if (!prompt) return message.reply('Please provide a prompt!');
try {
const result = await rexzimagine.response(prompt);
const imagePath = './image.png';
const imageStream = fs.createReadStream(imagePath);
const uploadStream = bucket.openUploadStream('image.png');
imageStream.pipe(uploadStream);
uploadStream.on('finish', async () => {
await message.channel.send({
content: `${message.author.toString()}, here is your imagination:`,
files: [imagePath]
});
});
} catch (error) {
console.error(error);
message.reply('Failed to generate image. Please try again.');
}
});
client.login(token);
```



Generates an image URL based on the given text prompt.
- `prompt` (string): A description of the image you want to generate.
- A `Promise<string>` containing the URL of the generated image.
- Simple API for generating AI-based images.
- Fast and reliable response times.
- Easily integrates with Node.js applications.
This project is licensed under the MIT License.
Contributions are welcome! Feel free to submit issues and pull requests to improve the package.
If you encounter any issues or have questions, please open an issue on the GitHub repository.
For further assistance:
Discord: [RexZ Development](https://discord.gg/AjH5wHWU4M)