|
| 1 | +# Athena Check Single - Image Classification CLI |
| 2 | + |
| 3 | +A command-line tool for classifying individual images using the Athena Classifier SDK. This sample demonstrates how to build a more comprehensive CLI application with the SDK. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- ✅ **Single image classification** with detailed results |
| 8 | +- 🖼️ **Multiple image format support** (JPEG, PNG, GIF, BMP, WebP) |
| 9 | +- 🔧 **Command-line argument parsing** with validation |
| 10 | +- 📊 **Formatted output** with verbose mode |
| 11 | +- ⚙️ **Environment-based configuration** |
| 12 | +- 🚨 **Comprehensive error handling** |
| 13 | +- 📋 **Deployment verification** |
| 14 | +- ⏱️ **Timeout protection** |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +```bash |
| 19 | +# Install dependencies |
| 20 | +npm install |
| 21 | + |
| 22 | +# Or install from parent directory |
| 23 | +npm install ../../ |
| 24 | +``` |
| 25 | + |
| 26 | +## Configuration |
| 27 | + |
| 28 | + |
| 29 | +Create a `.env` file in the samples directory with your Athena credentials as described in [the samples overview](../README.md). |
| 30 | + |
| 31 | +Then source the environment: |
| 32 | +```bash |
| 33 | +set -a && source ../.env |
| 34 | +``` |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +### Basic Usage |
| 39 | + |
| 40 | +```bash |
| 41 | +# Classify a single image |
| 42 | +node index.js ./my-image.jpg |
| 43 | + |
| 44 | +# Using npm script |
| 45 | +npm start ./my-image.jpg |
| 46 | +``` |
| 47 | + |
| 48 | +### Advanced Usage |
| 49 | +```bash |
| 50 | +# Verbose output with detailed information |
| 51 | +node index.js ./image.png --verbose |
| 52 | + |
| 53 | +# Force image format (useful for files without extensions) |
| 54 | +node index.js ./image --format jpeg |
| 55 | + |
| 56 | +# Override affiliate |
| 57 | +node index.js ./image.jpg --affiliate different-affiliate |
| 58 | +``` |
| 59 | + |
| 60 | +### Command Line Options |
| 61 | + |
| 62 | +| Option | Description | |
| 63 | +|--------|-------------| |
| 64 | +| `-h, --help` | Show help message | |
| 65 | +| `-v, --verbose` | Enable verbose output with detailed logs | |
| 66 | +| `-f, --format <format>` | Force image format (jpeg\|png\|gif\|bmp\|webp) | |
| 67 | +| `-a, --affiliate <name>` | Override affiliate name | |
| 68 | + |
| 69 | +## Supported Image Formats |
| 70 | + |
| 71 | +The tool automatically detects image format from file extensions: |
| 72 | + |
| 73 | +- **JPEG**: `.jpg`, `.jpeg` |
| 74 | +- **PNG**: `.png` |
| 75 | +- **GIF**: `.gif` |
| 76 | +- **BMP**: `.bmp` |
| 77 | +- **WebP**: `.webp` |
| 78 | + |
| 79 | +Use `--format` to override automatic detection. |
| 80 | + |
| 81 | +## Error Handling |
| 82 | + |
| 83 | +The tool provides error messages for common issues: |
| 84 | + |
| 85 | +- **Missing arguments**: Image path is required |
| 86 | +- **File not found**: Image file validation |
| 87 | +- **Invalid format**: Unsupported image formats |
| 88 | +- **Missing credentials**: Environment variable validation |
| 89 | +- **Network issues**: Connection and authentication errors |
| 90 | +- **Service errors**: Classification failures with correlation IDs |
| 91 | + |
| 92 | +## Architecture |
| 93 | + |
| 94 | +The CLI demonstrates several SDK integration patterns: |
| 95 | + |
| 96 | +1. **Configuration Management**: Environment-based configuration with validation |
| 97 | +2. **Error Handling**: Comprehensive error catching and user-friendly messages |
| 98 | +3. **Stream Processing**: Using streams for efficient image handling |
| 99 | +4. **Event-Driven Results**: Handling asynchronous classification results |
| 100 | +5. **Resource Management**: Proper connection lifecycle management |
| 101 | + |
| 102 | +This sample serves as a template for building CLI tools with the Athena SDK. |
0 commit comments