Extract and analyze metadata from AI-generated images, including model signatures, generation parameters, and provenance tracking
Project description
GLM Image Metadata Extractor - Python Implementation
This Python implementation was inspired by 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
cd python
pip install -r requirements.txt
Development Dependencies
pip install -e ".[dev]"
Usage
Basic Usage
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
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
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
@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
pytest
Code Formatting
black main.py
Type Checking
mypy main.py
Links
- Source: glmimage.app
- Repository: https://github.com/user/glmimage-app-oss
- PyPI Package: https://pypi.org/project/glmimage-app-oss
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glmimage_app_oss-1.0.0.tar.gz.
File metadata
- Download URL: glmimage_app_oss-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5fb92d265005f921da7343e2d92775d2b09d2d864339dd6c3946d0a3fd64a26
|
|
| MD5 |
bae9cde1949a3f28ac9875193eac0f82
|
|
| BLAKE2b-256 |
66978ec211bf0545eb20b2434b8b96cb421e9e654fc91b8c3938cce629406919
|
File details
Details for the file glmimage_app_oss-1.0.0-py3-none-any.whl.
File metadata
- Download URL: glmimage_app_oss-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2382ba797c33a787a6e6bb4da08f7d772de099392199d49e3f7784fda235e084
|
|
| MD5 |
eb604dbd22f5df66f7fe2e82174fd6b6
|
|
| BLAKE2b-256 |
f586c4c44f8637c71c394ac5eb1819061362b7a2210eb1a68f8cf19f5f7998dc
|