Skip to content

Commit

Permalink
feat: add watch mode and skip option
Browse files Browse the repository at this point in the history
  • Loading branch information
tychenjiajun committed Sep 2, 2024
1 parent 0e7c6cc commit 8d9f776
Show file tree
Hide file tree
Showing 14 changed files with 3,029 additions and 189 deletions.
8 changes: 5 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
src/**
node_modules/**
src/**/*
node_modules/**/*
pnpm-lock.yaml
renovate.json
.gitignore
.github/**/*
.prettierrc
.prettierrc
test/**/*
dist/test/**/*
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Exif AI

![NPM Downloads](https://img.shields.io/npm/dw/exif-ai)

## About

_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.

## Usage Example
Expand All @@ -26,18 +30,20 @@ exif-ai -i example.jpeg -a ollama

Required options:

- `-i, --input <value>` Path to the input image file.
- `-a, --api-provider <value>` Name of the AI provider to use (`ollama` for Ollama or `zhipu` for ZhipuAI).

Optional options:

- `-p, --prompt [value]`: Custom prompt for the AI provider. Defaults to a generic image description prompt.
- `-m, --model [value]`: Specify the AI model to use, if supported by the provider.
- `-t, --tags [value...]`: EXIF tags to write the description to. Defaults to common description tags.
- `-i, --input <file>` Path to the input image file.
- `-p, --prompt <text>`: Custom prompt for the AI provider. Defaults to a generic image description prompt.
- `-m, --model <name>`: Specify the AI model to use, if supported by the provider.
- `-t, --tags <tags...>`: EXIF tags to write the description to. Defaults to common description tags.
- `-v, --verbose`: Enable verbose output for debugging.
- `-d, --dry-run`: Preview the AI-generated description without writing to the image file.
- `--exif-tool-write-args [value...]`: Additional ExifTool arguments for writing metadata.
- `--provider-args [value...]`: Additional arguments for the AI provider.
- `--exif-tool-write-args <args...>`: Additional ExifTool arguments for writing metadata.
- `--provider-args <args...>`: Additional arguments for the AI provider.
- `-w, --watch <path>`: Watch directory for new files to process.
- `-s, --skip`: Skip if EXIF tags already exist in the file.

Example usage:

Expand All @@ -62,6 +68,8 @@ const options = {
dry: false, // Optional: Perform a dry run without writing to the file
writeArgs: [], // Optional: Additional arguments for EXIF write task
providerArgs: [], // Optional: Additional arguments for the AI provider
skip: false, // Optional: Skip if EXIF tags already exist in the file
watch: false, // Optional: Watch directory for new files to process
};

execute(options)
Expand All @@ -87,8 +95,8 @@ Exif AI relies on API providers to generate image descriptions. Currently, we su

### Supported Providers

ZhipuAI: A leading AI service provider. Requires an API key.
Ollama: A local AI service that runs on your machine, eliminating the need for an API key.
- ZhipuAI: A leading AI service provider. Requires an API key.
- Olama: A local AI service that runs on your machine, eliminating the need for an API key.

### Custom Providers

Expand Down
16 changes: 16 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginPromise from "eslint-plugin-promise";
import nodePlugin from "eslint-plugin-node";
import eslintPluginUnicorn from "eslint-plugin-unicorn";

export default [
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
nodePlugin.configs["flat/recommended-script"],
pluginPromise.configs["flat/recommended"],
eslintPluginUnicorn.configs.recommended,
...tseslint.configs.recommended,
];
27 changes: 23 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{
"name": "exif-ai",
"version": "1.1.1",
"version": "1.2.0",
"description": "A Node.js CLI and library that uses Ollama or ZhipuAI to intelligently write image description to exif metadata by it's content.",
"homepage": "https://github.com/tychenjiajun/exif-ai",
"repository": {
"type": "git",
"url": "https://github.com/tychenjiajun/exif-ai.git"
},
"bugs": {
"url": "https://github.com/tychenjiajun/exif-ai/issues"
},
"scripts": {
"build": "tsc",
"watch": "tsc --watch"
"build": "tsc -p tsconfig.build.json",
"clean": "rimraf dist",
"watch": "tsc --watch -p tsconfig.build.json",
"test": "vitest"
},
"engines": {
"node": ">=18"
Expand Down Expand Up @@ -36,14 +46,23 @@
},
"license": "GPL-2.0-only",
"dependencies": {
"chokidar": "^3.6.0",
"commander": "^12.1.0",
"exiftool-vendored": "^28.2.1",
"ollama": "^0.5.8",
"sharp": "^0.33.5"
},
"devDependencies": {
"@eslint/js": "^9.9.1",
"@types/node": "^22.5.1",
"eslint": "^9.9.1",
"eslint-plugin-n": "^17.10.2",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-unicorn": "^55.0.0",
"globals": "^15.9.0",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.5.4",
"typescript-eslint": "^8.3.0",
"vitest": "^2.0.5"
}
}
Loading

0 comments on commit 8d9f776

Please sign in to comment.