Skip to main content

Manipulate File metadata like a wizard-engineer!

Project description

Logo

MetaMancer is a Python library for reading, writing, and manipulating metadata in files, specifically photos and videos.

Features

  • Unified Metadata Interface: Access EXIF, IPTC, and XMP metadata through a single, consistent API
  • Intelligent Caching: Improve performance with built-in TTL caching of metadata
  • GPS Handling: Extract coordinates, generate map URLs, and work with location data
  • Spatial Analysis: Cluster images by location and generate interactive maps
  • Date Extraction: Intelligently determine the most accurate creation date from various metadata information
  • Camera Information: Extract and manipulate camera and photographer details
  • Keyword Management: Add, remove, and manage keywords and tags

Installation

pip install MetaMancer

Usage

Basic Metadata Access

from metamancer import MetaMancer

# Get metadata for an image file
metadata = MetaMancer.get_metadata('path/to/image.jpg')  # Provide str or Path

# Access specific metadata fields
date = metadata.date
camera = metadata.camera
title = metadata.title
keywords = metadata.keywords

# Check if a specific field exists
if 'Exif.DateTimeOriginal' in metadata:
    print(f'Original date: {metadata['Exif.DateTimeOriginal']}')

# Modify metadata
metadata.title = 'My Vacation Photo'
metadata.add_keyword('vacation', 'beach', 'summer')

Caching for Performance

from pathlib import Path
from metamancer import MetaMancer

file_path = Path('large_image.jpg')

# First access will parse the file
metadata = MetaMancer.get_metadata(file_path)

# Subsequent accesses will use the cached data (much faster)
metadata = MetaMancer.get_metadata(file_path)

# Check if a file's metadata is cached
is_cached = MetaMancer.is_cached(file_path)

# Clear cache for a specific file
MetaMancer.clear(file_path)

# Clear entire cache
MetaMancer.clear()

Location and Mapping

from pathlib import Path
from metamancer import MetaMancer
import glob

# Get all jpg files in a directory
image_files = [Path(f) for f in glob.glob('vacation_photos/*.jpg')]

# Generate an interactive map with all geotagged photos
MetaMancer.generate_photo_map(image_files, 'vacation_map.html')

# Get coordinates for a specific image
metadata = MetaMancer.get_metadata(image_files[0])
if metadata.has_location():
    lat, lon = metadata.get_gps_coords()
    map_url = metadata.get_gps_url()  # Google Maps URL
    print(f'Photo taken at: {lat}, {lon}')
    print(f'View on map: {map_url}')

Spatial Clustering

# Cluster images by location
spatial_strata = MetaMancer.cluster(image_files)

# Access files in the root level
print(f'Total files: {len(spatial_strata.files)}')

# Access files in a specific location cluster
if 'Beach' in spatial_strata._nested_files:
    beach_photos = spatial_strata['Beach'].files
    print(f'Beach photos: {len(beach_photos)}')

TODO

This library is currently in its Alpha release. It is in active development, but there is still a lot of work to do, including:

  • Fully documented functions
  • More detailed examples, emphasizing various classes
  • Many more fields supported (only started with the bare minimum)
  • Setting/modifying metadata values
  • Check in test code (once it doesn't involve personal photos)
  • Video file support
  • Configuration, specifically around caching
  • More thoughtful README
  • More world-building!
  • Links to projects that use MetaMancer

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metamancer-0.0.2a0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metamancer-0.0.2a0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file metamancer-0.0.2a0.tar.gz.

File metadata

  • Download URL: metamancer-0.0.2a0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.3 CPython/3.14.2 Linux/6.11.0-1018-azure

File hashes

Hashes for metamancer-0.0.2a0.tar.gz
Algorithm Hash digest
SHA256 757cb5d250def0717b53bf3783fc15784a3dc9d49933c5503caed671bcc2f3bd
MD5 8bc93002809ff92ab781057b88f78467
BLAKE2b-256 41dfdb15ef4f30c1b869476ed6828dc90beb0944a99be6a4f18d4ba4a64a5c01

See more details on using hashes here.

File details

Details for the file metamancer-0.0.2a0-py3-none-any.whl.

File metadata

  • Download URL: metamancer-0.0.2a0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.3 CPython/3.14.2 Linux/6.11.0-1018-azure

File hashes

Hashes for metamancer-0.0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6415c1d02ac20bf2dcacd34012216431785ca838d3e8cf01a0bd9717dda8659
MD5 2958cf403a22af14781fc63fb6e8f95e
BLAKE2b-256 35fa7dcd04d2c9b516f34e4bdb6666cb1b80b41eb3556813a0a7504fbaa7e31e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page