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.
Metadata
Release files for glmimage-app-oss 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| glmimage_app_oss-1.0.0.tar.gz | 5.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| glmimage_app_oss-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / glmimage_app_oss-1.0.0.tar.gz
| Download URL | glmimage_app_oss-1.0.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5fb92d265005f921da7343e2d92775d2b09d2d864339dd6c3946d0a3fd64a26
|
|
BLAKE2b-256 checksum How to use checksums |
66978ec211bf0545eb20b2434b8b96cb421e9e654fc91b8c3938cce629406919
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / glmimage_app_oss-1.0.0-py3-none-any.whl
| Download URL | glmimage_app_oss-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2382ba797c33a787a6e6bb4da08f7d772de099392199d49e3f7784fda235e084
|
|
BLAKE2b-256 checksum How to use checksums |
f586c4c44f8637c71c394ac5eb1819061362b7a2210eb1a68f8cf19f5f7998dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for glmimage-app-oss 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.