|
1 | 1 | # Exif AI |
2 | 2 |
|
3 | | -*Exif AI* is a CLI tool for writing AI-generated image descriptions to metadata. |
| 3 | +_Exif AI_ is a powerful CLI tool designed to write AI-generated image descriptions directly into the metadata of image files. This tool leverages advanced AI models to analyze image content and generate descriptive metadata, enhancing the accessibility and searchability of your images. |
4 | 4 |
|
5 | 5 | ## Usage Example |
6 | 6 |
|
7 | | -Without Installation |
| 7 | +### CLI |
| 8 | + |
| 9 | +#### Without Installation |
| 10 | + |
| 11 | +You can run Exif AI directly using npx without installing it globally: |
8 | 12 |
|
9 | 13 | ```bash |
10 | | -ZHIPUAI_API_KEY=Your_Key npx exif-ai -i example.jpeg -a zhipu |
| 14 | +npx exif-ai -i example.jpeg -a ollama |
11 | 15 | ``` |
12 | 16 |
|
13 | | -With Installation |
| 17 | +#### With Installation |
| 18 | + |
| 19 | +If you have installed Exif AI globally, you can run it directly from the command line: |
14 | 20 |
|
15 | 21 | ```bash |
16 | | -ZHIPUAI_API_KEY=Your_Key exif-ai -i example.jpeg -a zhipu |
| 22 | +exif-ai -i example.jpeg -a ollama |
| 23 | +``` |
| 24 | + |
| 25 | +#### Options |
| 26 | + |
| 27 | +Required options: |
| 28 | + |
| 29 | +- `-i, --input <value>` Path to the input image file. |
| 30 | +- `-a, --api-provider <value>` Name of the AI provider to use (`ollama` for Ollama or `zhipu` for ZhipuAI). |
| 31 | + |
| 32 | +Optional options: |
| 33 | + |
| 34 | +- `-p, --prompt [value]`: Custom prompt for the AI provider. Defaults to a generic image description prompt. |
| 35 | +- `-m, --model [value]`: Specify the AI model to use, if supported by the provider. |
| 36 | +- `-t, --tags [value...]`: EXIF tags to write the description to. Defaults to common description tags. |
| 37 | +- `-v, --verbose`: Enable verbose output for debugging. |
| 38 | +- `-d, --dry-run`: Preview the AI-generated description without writing to the image file. |
| 39 | +- `--exif-tool-write-args [value...]`: Additional ExifTool arguments for writing metadata. |
| 40 | +- `--provider-args [value...]`: Additional arguments for the AI provider. |
| 41 | + |
| 42 | +Example usage: |
| 43 | + |
| 44 | +```bash |
| 45 | +exif-ai -i example.jpg -a ollama -p "Describe this landscape photo." |
| 46 | +``` |
| 47 | + |
| 48 | +### Library |
| 49 | + |
| 50 | +To use Exif AI as a library in your project, import it and use the provided functions: |
| 51 | + |
| 52 | +```typescript |
| 53 | +import { execute } from "exif-ai"; |
| 54 | + |
| 55 | +const options = { |
| 56 | + path: "example.jpeg", |
| 57 | + provider: "ollama", |
| 58 | + model: "moondream", // Optional: specify the model if required by the provider |
| 59 | + tags: ["XPComment", "Description", "ImageDescription", "Caption-Abstract"], // Optional: specify the EXIF tags to write |
| 60 | + prompt: "请使用中文描述这个图片。", // Optional: specify the prompt for the AI provider |
| 61 | + verbose: false, // Optional: enable verbose logging |
| 62 | + dry: false, // Optional: perform a dry run without writing to the file |
| 63 | + writeArgs: [], // Optional: additional arguments for EXIF write task |
| 64 | + providerArgs: [], // Optional: additional arguments for the AI provider |
| 65 | +}; |
| 66 | +execute(options) |
| 67 | + .then(() => { |
| 68 | + console.log("Image description has been written to EXIF metadata."); |
| 69 | + }) |
| 70 | + .catch((error) => { |
| 71 | + console.error("An error occurred:", error); |
| 72 | + }); |
17 | 73 | ``` |
18 | 74 |
|
19 | 75 | ## Installation |
20 | 76 |
|
| 77 | +To install Exif AI globally, use the following command: |
| 78 | + |
21 | 79 | ```bash |
22 | 80 | npm install -g exif-ai |
23 | 81 | ``` |
24 | 82 |
|
25 | 83 | ## API Providers |
26 | 84 |
|
27 | | -Exif AI requires an API provider to generate descriptions from images. Currently, we have only one built-in provider, ZhipuAI. You should have a ZhipuAI API key before using Exif AI. |
| 85 | +Exif AI relies on API providers to generate image descriptions. Currently, we support two providers: ZhipuAI and Ollama. |
| 86 | + |
| 87 | +### Supported Providers |
| 88 | + |
| 89 | +ZhipuAI: A leading AI service provider. Requires an API key. |
| 90 | +Ollama: A local AI service that runs on your machine, eliminating the need for an API key. |
| 91 | + |
| 92 | +### Custom Providers |
| 93 | + |
| 94 | +You can also develop your own custom provider by implementing the provider interface. This allows you to integrate with other AI services or customize the description generation process. |
28 | 95 |
|
29 | | -You can also build your own provider by implementing the provider interface. |
| 96 | +## Configuration |
| 97 | + |
| 98 | +### Setting API Keys (for ZhipuAI) |
| 99 | + |
| 100 | +To use ZhipuAI, you need to set the API key. You can do this by setting an environment variable: |
| 101 | + |
| 102 | +```bash |
| 103 | +export ZHIPUAI_API_KEY=your_zhipuai_api_key |
| 104 | +``` |
| 105 | + |
| 106 | +### Ollama Configuration |
| 107 | + |
| 108 | +Ollama runs locally and does not require an API key. Ensure that Ollama is installed and properly configured on your machine. Refer to the [Ollama GitHub repository](https://github.com/ollama/ollama) for installation and setup instructions. |
30 | 109 |
|
31 | 110 | ## Develop |
32 | 111 |
|
33 | | -1. Clone the Repository |
| 112 | +### Prerequisites |
| 113 | + |
| 114 | +- Node.js >=18 |
| 115 | +- pnpm |
| 116 | + |
| 117 | +### Clone the Repository |
| 118 | + |
| 119 | +First, clone the Exif AI repository to your local machine: |
34 | 120 |
|
35 | 121 | ```bash |
36 | 122 | git clone https://github.com/tychenjiajun/exif-ai.git |
37 | 123 | cd exif-ai |
38 | 124 | ``` |
39 | 125 |
|
40 | | -2. Install Dependencies |
| 126 | +### Install Dependencies |
| 127 | + |
| 128 | +Next, install the required dependencies using `pnpm`. |
41 | 129 |
|
42 | 130 | ```bash |
43 | 131 | pnpm install |
44 | 132 | ``` |
45 | 133 |
|
46 | | - |
| 134 | +### Build |
| 135 | + |
| 136 | +```bash |
| 137 | +pnpm run build |
| 138 | +``` |
| 139 | + |
| 140 | +### Watch |
| 141 | + |
| 142 | +```bash |
| 143 | +pnpm run watch |
| 144 | +``` |
0 commit comments