{"id":25925236,"url":"https://github.com/bigsk1/terminal-image","last_synced_at":"2026-06-12T09:31:41.179Z","repository":{"id":278899508,"uuid":"937110340","full_name":"bigsk1/terminal-image","owner":"bigsk1","description":"Script to generate images using OpenAI's API, upload them to Cloudflare Images, and get back hosted URLs directly in your terminal","archived":false,"fork":false,"pushed_at":"2025-02-24T05:14:47.000Z","size":612,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-07T17:58:55.957Z","etag":null,"topics":["cloudflare-image","dalle3","openai-api","openai-images","script-kiddie"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigsk1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"bigsk1"}},"created_at":"2025-02-22T11:08:43.000Z","updated_at":"2025-05-25T05:27:41.000Z","dependencies_parsed_at":"2025-02-22T12:36:37.348Z","dependency_job_id":null,"html_url":"https://github.com/bigsk1/terminal-image","commit_stats":null,"previous_names":["bigsk1/terminal-image"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bigsk1/terminal-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsk1%2Fterminal-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsk1%2Fterminal-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsk1%2Fterminal-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsk1%2Fterminal-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigsk1","download_url":"https://codeload.github.com/bigsk1/terminal-image/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsk1%2Fterminal-image/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34238713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-image","dalle3","openai-api","openai-images","script-kiddie"],"created_at":"2025-03-03T18:40:26.418Z","updated_at":"2026-06-12T09:31:41.162Z","avatar_url":"https://github.com/bigsk1.png","language":"Python","funding_links":["https://github.com/sponsors/bigsk1"],"categories":[],"sub_categories":[],"readme":"# Cloudflare Terminal Image Generator (`cf`)\n\nThis Python script provides a quick and easy way to generate images using OpenAI's API, upload them to Cloudflare Images, and get back hosted URLs directly in your terminal. Simply type a description (e.g., `python cf.py \"image of a brown dog with space background\"`), and the script will generate an image, upload it to Cloudflare, and display clickable URLs—all with a professional, progress-tracked interface powered by the `rich` library.\n\nPerfect for developers, designers, or anyone needing fast image generation and hosting without the hassle of saving files locally. Cloudflare Images serves the uploaded image in any size or format as needed, making them versatile for projects.\n\n---\n\n## Features\n\n- **Cross-Platform**: Works on Windows, macOS, and Linux.\n- **Image Generation**: Creates one image per request using DALL-E 3 in either 1024x1024 or 1792x1024.\n- **Secure**: Stores API keys in environment variables, not the script.\n- **Professional Output**: Uses `rich` for progress bars and formatted terminal display.\n- **Image Preview**: Provides a low-resolution preview of your image in the terminal.\n- **History Logging**: Stores generated images with timestamps and expiration status.\n- **Simple Usage**: Run with a single command and your image description.\n\n---\n\n## Example\n\n![cf3](cf3.png)\n\nClick on the url to view the high res in browser or copy and paste the image url for all your needs!\n\n---\n\n## Prerequisites\n\nBefore using the script, ensure you have:\n- **Python 3.x** installed ([Download Python](https://www.python.org/downloads/)).\n- A terminal (e.g., Command Prompt, PowerShell, Bash, or Zsh).\n- API keys from OpenAI and Cloudflare (see below).\n\n---\n\n## Setup Instructions\n\n### Step 1: Clone the Repository\n\n```bash\ngit clone https://github.com/bigsk1/terminal-image.git\ncd terminal-image\npip install requests rich pillow\n```\n\nInstall optional image preview tools:\n```bash\nsudo apt install viu chafa -y  # Linux\n```\n\n---\n\n### Step 2: Obtain API Keys\n\n#### OpenAI API Key\n- Go to the [OpenAI Platform](https://platform.openai.com/).\n- Sign up or log in.\n- Navigate to the API section and create a new API key.\n- Copy the key (e.g., `sk-...`).\n\n#### Cloudflare API Token and Account ID\n- Log in to your [Cloudflare Dashboard](https://dash.cloudflare.com/).\n- Navigate to **Images \u003e API Tokens** (ensure Cloudflare Images is enabled).\n- Create a new API token with the **Cloudflare Images: Edit** permission.\n- Copy the token (`Acct. ID and Token`).\n- Note your **Account ID** (found under Account Home or in the URL `https://dash.cloudflare.com/\u003cACCOUNT_ID\u003e`).\n\n---\n\n### Step 3: Set Environment Variables\n\n#### On Linux/macOS\nOpen your shell configuration file (e.g., `~/.zshrc` or `~/.bashrc`):\n```bash\nsudo nano ~/.zshrc\n```\n\nAdd these lines:\n```bash\nexport OPENAI_API_KEY=\"your-openai-key\"\nexport CLOUDFLARE_API_TOKEN=\"your-cloudflare-token\"\nexport CLOUDFLARE_ACCOUNT_ID=\"your-account-id\"\n```\n\nSave and apply changes:\n```bash\nsource ~/.zshrc\n```\n\n#### On Windows\nOpen Command Prompt or PowerShell as Administrator and set the variables:\n```powershell\nsetx OPENAI_API_KEY \"your-openai-key\"\nsetx CLOUDFLARE_API_TOKEN \"your-cloudflare-token\"\nsetx CLOUDFLARE_ACCOUNT_ID \"your-account-id\"\n```\n\nClose and reopen your terminal.\n\n---\n\n## Usage\n\nNavigate to the repository folder:\n```bash\ncd terminal-image\n```\n\nRun the script with your image description:\n```bash\npython cf.py \"image of a brown dog with space background\"\n```\n\n### Additional Options\n| Option | Description |\n|--------|-------------|\n| `--wide` | Generate a **wide** image (1792x1024). |\n| `--expire 24h` | Set image to **auto-expire** after **24 hours**. |\n| `--expire 30d` | Set image to **auto-expire** after **30 days**. |\n| `--history` | View past image generations (URLs, prompts, and expiry status). |\n| `--help` | Show available options. |\n\n![cf2](cf2.png)\n\n\n### Example Commands:\n```bash\npython cf.py --wide \"futuristic cyberpunk city\"\npython cf.py --expire 24h \"a robot in the rain\"\npython cf.py --expire 30d --wide \"a space station in orbit\"\npython cf.py --history  # View previously generated images\n```\n![history](history.png)\n---\n\n### Optional: Alias cf for Easier Usage\n\nInstead of moving the script, you can create an alias to run it from anywhere:\n\nOn Linux/macOS\n\nOpen your shell config file:\n\n```bash\nnano ~/.zshrc  # or nano ~/.bashrc\n```\n\nAdd this line:\n\n```bash\nalias cf=\"python3 /path/to/terminal-image/cf.py\"\n```\n\nSave and apply changes:\n\n```bash\nsource ~/.zshrc  # If using Zsh\nsource ~/.bashrc  # If using Bash\n```\n\nNow, run it anywhere:\n\n```bash\ncf \"image of a brown dog with space background\"\n```\n\nOn Windows\n\nOpen PowerShell and add the alias:\n\n```bash\nNew-Alias -Name cf -Value \"C:\\path\\to\\cf.py\"\n```\n\nOr, create a batch file (cf.bat) in a directory included in PATH:\n\necho @echo off \u003e C:\\Windows\\cf.bat\necho python \"C:\\path\\to\\cf.py\" %%* \u003e\u003e C:\\Windows\\cf.bat\n\nNow, run it:\n\n```bash\ncf \"image of a brown dog with space background\"\n```\n\n\n---\n\n### Troubleshooting\n\n- **API Key Errors:** Verify the environment variables are set:\n  - Linux/macOS: `echo $OPENAI_API_KEY`\n  - Windows: `echo %OPENAI_API_KEY%`\n- **Network Issues:** Check your internet connection if you see \"Network Error.\"\n- **URLs Not Clickable:** Some terminals don’t support hyperlinks—copy and paste the URLs instead.\n- **Permission Denied (Linux/macOS):** Ensure the script is executable (`chmod +x cf.py`).\n\n### History File Not Being Created: If cf_history.json does not appear, ensure cf.py has correct ownership:\n\n```bash\nsudo chown $USER:$USER ~/path/to/cf.py\n```\n\nAlso, check directory permissions:\n\n```bash\nsudo chown -R $USER:$USER ~/path/to/terminal-image\nchmod u+w ~/path/to/terminal-image\n```\n\n---\n\n### Example Generated Image\n![dog](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/c22e978e-98f6-43e3-49ce-55fead71d000/public)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigsk1%2Fterminal-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigsk1%2Fterminal-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigsk1%2Fterminal-image/lists"}