# Bing Create
This is a simple lightweight reverse engineered [Bing Image Creator](https://bing.com/create) API made in python that allows you to quickly generate high quality AI images. This package was inspired by [BingImageCreator package](https://github.com/acheong08/BingImageCreator) and the main goal is to make better version of it.
**Advantages over the original package:**
- Actively maintained
- Lightweight
- Easier to use
- Ability to specify the number of images to generate
- Termux support
- Complete code rewrite
You can use it from console\terminal or integrate it to your python project. To get started read the instructions below.
## Installation
To install the package you can use pip:
```bash
pip install bing-create
```
or you can clone the repository and install it manually:
```bash
git clone https://github.com/Waenara/bing-create.git
cd bing_create
pip install .
```
## Usage
### Getting cookies
After installing the package as described above you will need to get your **_U** and **SRCHHPGUSR** cookies from [Bing](https://bing.com). You can do this by logging in to [Bing](https://bing.com), opening the developer tools (F12) and going to the console tab. Then you can run the following code:
```javascript
console.log(`_U:\n${document.cookie.match(/(?:^|;\s*)_U=(.*?)(?:;|$)/)[1]}\n\nSRCHHPGUSR:\n${document.cookie.match(/(?:^|;\s*)SRCHHPGUSR=(.*?)(?:;|$)/)[1]}`)
```
This will output your **_U** and **SRCHHPGUSR** cookies.
### Terminal\Console
If you are an average user you can use the package from the console\terminal.
After you installed the package and got the cookies. use the following command to get help, or you may enter arguments from below to generate images:
```bash
bing-create
```
**All arguments:**
- `--u` - Your **_U** cookie
- `--s` - Your **SRCHHPGUSR** cookie
- `--prompt` - Description of images you want to generate
- `--output` (Optional) - Path to directory where the images will be saved
- `--number` (Optional, default: 4) - Number of images to generate
- `--quiet` (Optional) - If present logging is disabled
### Integration to your python project
If you are a developer you can integrate the package to your python project. Here is an example of how you can use the package:
Synchronous:
```python
from bing_create.main import ImageGenerator
# Create an instance of the ImageGenerator class
generator = ImageGenerator(
auth_cookie_u='Your _U cookie',
auth_cookie_srchhpgusr='Your SRCHHPGUSR cookie'
)
# Generate 5 images from a text prompt
images = generator.generate(
prompt='A cute cat',
num_images=5
)
# Save the images to the directory called 'output'
generator.save(
images=images,
output_dir='output'
)
```
Asynchronous:
```python
import asyncio
from bing_create.main import AsyncImageGenerator
async def main():
# Create an instance of the AsyncImageGenerator class
generator = AsyncImageGenerator(
auth_cookie_u='Your _U cookie',
auth_cookie_srchhpgusr='Your SRCHHPGUSR cookie'
)
# Generate 5 images from a text prompt
images = await generator.generate(
prompt='A cute cat',
num_images=5
)
# Save the images to the directory called 'output'
await generator.save(
images=images,
output_dir='output'
)
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Waenara/bing-create",
"name": "bing-create",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "ai dall-e image bing api generator bing_create image-generator ig ic",
"author": "Waenara",
"author_email": "WaenaraCat@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b6/14/bcbeb75f7753995997e969d558771811c7cba54613f3ed233916894c8f08/bing_create-0.0.5.tar.gz",
"platform": null,
"description": "# Bing Create\r\nThis is a simple lightweight reverse engineered [Bing Image Creator](https://bing.com/create) API made in python that allows you to quickly generate high quality AI images. This package was inspired by [BingImageCreator package](https://github.com/acheong08/BingImageCreator) and the main goal is to make better version of it.\r\n\r\n**Advantages over the original package:**\r\n- Actively maintained\r\n- Lightweight\r\n- Easier to use\r\n- Ability to specify the number of images to generate\r\n- Termux support\r\n- Complete code rewrite\r\n\r\nYou can use it from console\\terminal or integrate it to your python project. To get started read the instructions below.\r\n\r\n## Installation\r\nTo install the package you can use pip:\r\n```bash\r\npip install bing-create\r\n```\r\nor you can clone the repository and install it manually:\r\n```bash\r\ngit clone https://github.com/Waenara/bing-create.git\r\ncd bing_create\r\npip install .\r\n```\r\n## Usage\r\n### Getting cookies\r\nAfter installing the package as described above you will need to get your **_U** and **SRCHHPGUSR** cookies from [Bing](https://bing.com). You can do this by logging in to [Bing](https://bing.com), opening the developer tools (F12) and going to the console tab. Then you can run the following code:\r\n```javascript\r\nconsole.log(`_U:\\n${document.cookie.match(/(?:^|;\\s*)_U=(.*?)(?:;|$)/)[1]}\\n\\nSRCHHPGUSR:\\n${document.cookie.match(/(?:^|;\\s*)SRCHHPGUSR=(.*?)(?:;|$)/)[1]}`)\r\n```\r\nThis will output your **_U** and **SRCHHPGUSR** cookies.\r\n\r\n### Terminal\\Console\r\nIf you are an average user you can use the package from the console\\terminal. \r\nAfter you installed the package and got the cookies. use the following command to get help, or you may enter arguments from below to generate images:\r\n```bash\r\nbing-create\r\n```\r\n**All arguments:**\r\n- `--u` - Your **_U** cookie\r\n- `--s` - Your **SRCHHPGUSR** cookie\r\n- `--prompt` - Description of images you want to generate\r\n- `--output` (Optional) - Path to directory where the images will be saved\r\n- `--number` (Optional, default: 4) - Number of images to generate\r\n- `--quiet` (Optional) - If present logging is disabled\r\n\r\n### Integration to your python project\r\nIf you are a developer you can integrate the package to your python project. Here is an example of how you can use the package:\r\n\r\nSynchronous:\r\n```python\r\nfrom bing_create.main import ImageGenerator\r\n\r\n# Create an instance of the ImageGenerator class\r\ngenerator = ImageGenerator(\r\n auth_cookie_u='Your _U cookie',\r\n auth_cookie_srchhpgusr='Your SRCHHPGUSR cookie'\r\n)\r\n\r\n# Generate 5 images from a text prompt\r\nimages = generator.generate(\r\n prompt='A cute cat',\r\n num_images=5\r\n)\r\n\r\n# Save the images to the directory called 'output'\r\ngenerator.save(\r\n images=images, \r\n output_dir='output'\r\n)\r\n```\r\n\r\nAsynchronous:\r\n```python\r\nimport asyncio\r\nfrom bing_create.main import AsyncImageGenerator\r\n\r\n\r\nasync def main():\r\n # Create an instance of the AsyncImageGenerator class\r\n generator = AsyncImageGenerator(\r\n auth_cookie_u='Your _U cookie',\r\n auth_cookie_srchhpgusr='Your SRCHHPGUSR cookie'\r\n )\r\n\r\n # Generate 5 images from a text prompt\r\n images = await generator.generate(\r\n prompt='A cute cat',\r\n num_images=5\r\n )\r\n\r\n # Save the images to the directory called 'output'\r\n await generator.save(\r\n images=images,\r\n output_dir='output'\r\n )\r\n\r\n\r\nasyncio.run(main())\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A simple lightweight AI Image Generator from text description using Bing Image Creator (DALL-E 3)",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/Waenara/bing-create",
"Support": "https://github.com/Waenara/bing-create/issues"
},
"split_keywords": [
"ai",
"dall-e",
"image",
"bing",
"api",
"generator",
"bing_create",
"image-generator",
"ig",
"ic"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b614bcbeb75f7753995997e969d558771811c7cba54613f3ed233916894c8f08",
"md5": "8937fa366d2f63ffc2c3abead8ec7b66",
"sha256": "ab9e07786dd420732a49fd18eb3eca6225fff663035db16011b71617cea3f707"
},
"downloads": -1,
"filename": "bing_create-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "8937fa366d2f63ffc2c3abead8ec7b66",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5013,
"upload_time": "2024-05-13T16:16:33",
"upload_time_iso_8601": "2024-05-13T16:16:33.534881Z",
"url": "https://files.pythonhosted.org/packages/b6/14/bcbeb75f7753995997e969d558771811c7cba54613f3ed233916894c8f08/bing_create-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-13 16:16:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Waenara",
"github_project": "bing-create",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "setuptools",
"specs": [
[
"~=",
"68.2.0"
]
]
},
{
"name": "aiofiles",
"specs": [
[
"~=",
"23.2.1"
]
]
},
{
"name": "httpx",
"specs": [
[
"~=",
"0.27.0"
]
]
}
],
"lcname": "bing-create"
}