Skip to content

crizmo/image2url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

Image2Url

NPM version

Convert images to urls
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Roadmap
  4. Contributing
  5. License
  6. Contact

About The Project

Convert images to urls using discord bot / imgbb api

  • How it works
    For discord:
    Images are sent to a discord channel that you specify.
    The bot will then get the proxy url of the image and then return it to you.

For imgbb:
Images are sent to imgbb database and then the url is returned to you.

(back to top)

Getting Started

For Discord

  1. Make a discord bot in discord developer portal
  2. Copy the token and paste it in the .env file named DISCORD_TOKEN
  3. Invite the bot to your server
  4. Get the channel id of the channel where you want to send the images
  5. Paste the channel id in the .env file named DISCORD_CHANNEL
  6. Check env_example file for more info - env_example
  7. Install the required packages - discord.js, dotenv, fs
  8. Install image2url using npm
    npm install image2url
  9. Require the package in your main file
    const image2url = require('image2url');

(back to top)

For Imgbb

  1. Make an account on imgbb
  2. Get the api key from the dashboard
  3. Paste the api key in the .env file named IMG_BB_KEY
  4. Install the required packages - axios, dotenv, fs, form-data

Functions

// Discord upload

image2url.init({
    token: process.env.DISCORD_TOKEN,
    channel: process.env.DISCORD_CHANNEL
});

image2url.upload('tests/kurizu.jpg', 'kurizu pfp').then(url => {
    console.log(url);
});


// Imgbb upload
const imagePath = 'tests/kurizu.jpg';

image2url.imgbb_upload(imagePath, process.env.IMG_BB_KEY)
    .then((url) => {
        console.log('Image uploaded successfully. URL:', url);
    })
    .catch((error) => {
        console.error('Image upload failed with error:', error);
    });

Check env_example file for more info - env_example

(back to top)

Usage

const image2url = require('image2url');
require('dotenv').config()

// Discord upload

image2url.init({
    token: process.env.DISCORD_TOKEN,
    channel: process.env.DISCORD_CHANNEL
});

image2url.upload('tests/kurizu.jpg', 'kurizu pfp').then(url => {
    console.log(url);
});


// Imgbb upload
const imagePath = 'tests/kurizu.jpg';

image2url.imgbb_upload(imagePath, process.env.IMG_BB_KEY)
    .then((url) => {
        console.log('Image uploaded successfully. URL:', url);
    })
    .catch((error) => {
        console.error('Image upload failed with error:', error);
    });

Note:

  1. tests/kurizu.jpg is the path to the image you want to send.
  2. kurizu pfp is the name of the image.
  3. The url will have the name that you specified. which in this case is kurizu pfp.

(back to top)

For more information on how to use it visit

(back to top)

Roadmap

  • Add Changelog
  • Add Tests
  • Add Additional Templates w/ Examples
  • Add Support for more image formats
  • Documentation
    • Website
    • Examples
    • Wiki
  • Add Support for more platforms

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Package Made by: kurizu.taz on discord
Github - https://github.com/crizmo/image2url