Skip to main content

MetaToolkit

PyPI version Python version License: MIT

A powerful Python library for processing metadata of images, videos, and audio files. Supports adding, reading, and managing metadata information for various media files.

Features

  • 🖼️ Image Metadata Processing - Support for EXIF, XMP metadata in JPEG, PNG formats
  • 🎬 Video Metadata Processing - Support for metadata tags in MP4, AVI and other formats
  • 🎵 Audio Metadata Processing - Support for ID3 tags in MP3, WAV and other formats
  • 📝 Custom Metadata - Support for adding custom metadata fields
  • 🔧 Command Line Tool - Convenient command-line interface
  • 🐍 Python API - Simple and easy-to-use Python interface

Installation

Install from PyPI

pip install metatoolkit

Install from Source

git clone https://github.com/ihmily/metatoolkit.git
cd metatoolkit
pip install -e .

Requirements

  • Python >= 3.10
  • Pillow >= 9.5.0
  • pyexiv2 >= 2.15.4

Note: Video and audio metadata writing functionality requires FFmpeg environment. Please ensure FFmpeg is properly installed on your system and accessible from the command line.

Quick Start

Image Metadata Processing

import metatoolkit
from datetime import datetime

# Add custom metadata to image
custom_metadata = {
    "model": "stable-diffusion-v1.5",
    "prompt": "A beautiful landscape",
    "timestamp": datetime.now().isoformat(),
    "creator": "MetaToolkit"
}

# Add metadata
output_path = metatoolkit.add_image_metadata("input.png", custom_metadata=custom_metadata)

# Read metadata
metadata = metatoolkit.read_image_metadata(output_path)
print(metadata)

Video Metadata Processing

import metatoolkit

# Add video metadata
video_metadata = {
    "title": "My Video",
    "description": "This is a test video",
    "author": "MetaToolkit User",
    "creation_date": "2024-01-01"
}

# Add metadata
metatoolkit.add_video_metadata("input.mp4", custom_metadata=video_metadata)

# Read metadata
metadata = metatoolkit.read_video_metadata("input.mp4")
print(metadata)

Audio Metadata Processing

import metatoolkit

# Add audio metadata
audio_metadata = {
    "title": "My Music",
    "artist": "Artist Name",
    "album": "Album Name",
    "year": "2024"
}

# Add metadata
metatoolkit.add_audio_metadata("input.mp3", custom_metadata=audio_metadata)

# Read metadata
metadata = metatoolkit.read_audio_metadata("input.mp3")
print(metadata)

Command Line Tool

MetaToolkit provides a convenient command-line tool that can be used directly in the terminal:

# Show help
metatoolkit --help

# Add image metadata
metatoolkit image add image.png --field MyTag='{\"title\":\"My Image\",\"author\":\"User\"}'

# Read image metadata
metatoolkit image read image.png

# Add video metadata
metatoolkit video add video.mp4 --field MyTag1=MyTest01 --field MyTag2=MyTest02

# Read video metadata
metatoolkit video read video.mp4

# Add audio metadata
metatoolkit audio add audio.mp3 --field MyTag1=MyTest01 --field MyTag2=MyTest02 --field MyTag3=MyTest03

# Read audio metadata
metatoolkit audio read audio.mp3

API Reference

Image Processing

  • add_image_metadata(image_path, custom_metadata=None, output_path=None) - Add image metadata
  • read_image_metadata(image_path) - Read image metadata
  • get_all_image_metadata(image_path) - Get all image metadata

Video Processing

  • add_video_metadata(video_path, custom_metadata=metadata_dict) - Add video metadata
  • read_video_metadata(video_path) - Read video metadata
  • get_all_video_metadata(video_path) - Get all video metadata

Audio Processing

  • add_audio_metadata(audio_path, custom_metadata=metadata_dict) - Add audio metadata
  • read_audio_metadata(audio_path) - Read audio metadata
  • get_all_audio_metadata(audio_path) - Get all audio metadata

Supported Formats

Image Formats

  • JPEG (.jpg, .jpeg)
  • PNG (.png)

Video Formats

  • MP4 (.mp4)
  • AVI (.avi)
  • MOV (.mov)
  • MKV (.mkv)

Audio Formats

  • MP3 (.mp3)
  • WAV (.wav)
  • FLAC (.flac)
  • M4A (.m4a)
  • OGG (.ogg)
  • AAC (.aac)

Related Tools

Viewing and Verifying Metadata

ExifTool

ExifTool is a powerful command-line tool for reading, writing, and editing metadata in various file formats. It's particularly useful for viewing and verifying metadata in images.

# View all metadata in an image
exiftool image.png

# View metadata in a video
exiftool video.mp4

# View metadata in a audio
exiftool audio.mp3

FFprobe

FFprobe is part of the FFmpeg suite and is excellent for analyzing audio and video files.

# View video metadata
ffprobe -v quiet -print_format json -show_format -show_streams video.mp4

# View audio metadata
ffprobe -v quiet -print_format json -show_format audio.mp3

Installation

# Install ExifTool (Windows)
# Download from https://exiftool.org/

# Install ExifTool (macOS)
brew install exiftool

# Install ExifTool (Ubuntu/Debian)
sudo apt-get install libimage-exiftool-perl

# Install FFmpeg/FFprobe (Windows)
# Download from https://ffmpeg.org/download.html

# Install FFmpeg/FFprobe (macOS)
brew install ffmpeg

# Install FFmpeg/FFprobe (Ubuntu/Debian)
sudo apt-get install ffmpeg

Examples

Check the examples/basic_usage.py file for more usage examples.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for version update history.

Contact

Acknowledgments

Thanks to all the developers who contributed to this project!

Metadata

Release files for metatoolkit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metatoolkit 0.1.1
File Size Uploaded
metatoolkit-0.1.1.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metatoolkit 0.1.1
File Interpreter ABI Platform
metatoolkit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / metatoolkit-0.1.1.tar.gz

Download URL metatoolkit-0.1.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
24d04b2fb579c66ea30a7a4f541f82603495b4bd7d5233810b499f4c76d317e5
BLAKE2b-256 checksum
How to use checksums
34b7f4ac143ccb39d0115b684a4c8f9018b496b7a9c8ce4ab87ba2b31e4710f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.10.13 Windows/10

Release files / metatoolkit-0.1.1-py3-none-any.whl

Download URL metatoolkit-0.1.1-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1cb9a333706ea0a28349c91f9d3c24a7268e3d03f55880d9a0965e9891ee323
BLAKE2b-256 checksum
How to use checksums
d63f04c09f1c15c165156b64d5520adb4d3130c8d87067eb1a93b3981b1d9087
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.10.13 Windows/10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page