semvec/pypi-packages huggingface dataset:
glmimage-app-oss 1.0.0
Extract and analyze metadata from AI-generated images, including model signatures, generation parameters, and provenance tracking
License: MIT
Requires Python: >=3.8
Keywords: ai, image, metadata, exif, png, glm, provenance, image-analysis, ai-detection, attribution

# GLM Image Metadata Extractor - Python Implementation

This Python implementation was inspired by [glmimage.app](https://glmimage.app). It provides efficient extraction and analysis of metadata from AI-generated images, including model signatures, generation parameters, and provenance tracking.

## Features

- **PNG Chunk Parsing**: Pure Python implementation for reading PNG chunks
- **EXIF Metadata Extraction**: Extract standard EXIF data from images
- **AI Signature Validation**: Verify and validate AI model signatures
- **Provenance Tracking**: Track the origin and generation parameters of AI images
- **Type Hints**: Full type annotations for better IDE support
- **Dataclasses**: Modern Python dataclass-based API

## Installation

```bash
cd python
pip install -r requirements.txt
```

### Development Dependencies

```bash
pip install -e ".[dev]"
```

## Usage

### Basic Usage

```python
from main import extract_ai_metadata, print_metadata_summary

# Extract metadata from an image
metadata = extract_ai_metadata("generated-image.png")
print_metadata_summary(metadata)
```

### Creating Metadata Programmatically

```python
from main import create_metadata_from_data, validate_ai_signature

metadata = create_metadata_from_data({
    "model": "GLM-4V-Image",
    "prompt": "A beautiful sunset over mountains",
    "parameters": {"steps": "50", "guidance": "7.5"},
    "width": 1024,
    "height": 1024,
    "format": "PNG"
})

is_valid = validate_ai_signature(metadata)
print(f"Valid: {is_valid}")
```

### Running the Demo

```bash
python main.py
```

## API Reference

### `extract_ai_metadata(image_path: str) -> AIMetadata`

Extracts AI metadata from an image file. Returns an `AIMetadata` dataclass.

### `validate_ai_signature(metadata: AIMetadata) -> bool`

Validates the AI model signature in the metadata. Returns `True` if valid.

### `embed_provenance_metadata(metadata: AIMetadata, source: str) -> None`

Adds provenance information to the metadata object.

### `print_metadata_summary(metadata: AIMetadata) -> None`

Prints a formatted summary of the extracted metadata to the console.

### `create_metadata_from_data(data: dict) -> AIMetadata`

Creates a new `AIMetadata` instance from a dictionary.

## Data Structures

```python
@dataclass
class AIMetadata:
    model: str = ""
    prompt: str = ""
    parameters: Dict[str, str] = field(default_factory=dict)
    timestamp: str = ""
    provenance: str = ""
    signature: str = ""
    width: int = 0
    height: int = 0
    format: str = ""
```

## Testing

```bash
pytest
```

## Code Formatting

```bash
black main.py
```

## Type Checking

```bash
mypy main.py
```

## Links

- **Source**: [glmimage.app](https://glmimage.app)
- **Repository**: https://github.com/user/glmimage-app-oss
- **PyPI Package**: https://pypi.org/project/glmimage-app-oss

## License

MIT License - see [LICENSE](../LICENSE) for details.