or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

core-interface.mdexception-handling.mdexperimental-features.mdhelper-interface.mdindex.md
tile.json

tessl/pypi-pyexiftool

Python wrapper for exiftool to extract and manipulate metadata from image, video, and other media files

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyexiftool@0.5.x

To install, run

npx @tessl/cli install tessl/pypi-pyexiftool@0.5.0

index.mddocs/

PyExifTool

A Python library that provides a wrapper interface to communicate with Phil Harvey's ExifTool command-line application for extracting and manipulating metadata from image, video, and other media files. PyExifTool runs ExifTool in batch mode for efficient processing of multiple files and supports reading and writing EXIF, IPTC, XMP, and other metadata formats.

Package Information

  • Package Name: PyExifTool
  • Language: Python
  • Installation: pip install PyExifTool
  • Minimum Python Version: 3.6+
  • External Dependency: Requires Phil Harvey's ExifTool command-line application

Core Imports

import exiftool

Common pattern for helper class:

from exiftool import ExifToolHelper

Low-level access:

from exiftool import ExifTool

Exception handling:

from exiftool import exceptions

Basic Usage

import exiftool

# Recommended approach using ExifToolHelper
files = ["image1.jpg", "image2.png", "video.mp4"]

with exiftool.ExifToolHelper() as et:
    # Get all metadata
    metadata = et.get_metadata(files)
    for data in metadata:
        print(f"File: {data['SourceFile']}")
        print(f"Date: {data.get('EXIF:DateTimeOriginal', 'N/A')}")
    
    # Get specific tags
    tags = et.get_tags(files, ['EXIF:Make', 'EXIF:Model'])
    
    # Set tags
    et.set_tags('image.jpg', {'EXIF:Artist': 'John Doe'})

# Low-level approach for advanced usage
with exiftool.ExifTool() as et:
    # Execute direct exiftool commands
    result = et.execute_json('-j', 'image.jpg')
    
    # Execute raw commands
    output = et.execute('-n', '-g', 'image.jpg')

Architecture

PyExifTool provides three main classes for different use cases:

  • ExifTool: Core low-level interface that manages the exiftool subprocess and provides direct command execution
  • ExifToolHelper: User-friendly wrapper that adds convenience methods, error checking, and auto-start functionality
  • ExifToolAlpha: Experimental class with additional specialized functionality for niche use cases

The library runs ExifTool in batch mode using subprocess communication, keeping a single ExifTool process running for multiple operations to maximize performance. All classes support context manager patterns for automatic resource management.

Capabilities

Core Interface

Low-level interface to the exiftool subprocess with direct command execution, JSON parsing, and subprocess lifecycle management. Provides maximum control and flexibility for advanced users.

class ExifTool:
    def __init__(self, executable=None, common_args=None, win_shell=False, config_file=None, encoding=None, logger=None): ...
    def run(self): ...
    def terminate(self, timeout=30, _del=False): ...
    def execute(self, *params, raw_bytes=False): ...
    def execute_json(self, *params): ...

Core Interface

Helper Interface

User-friendly wrapper with convenience methods for common metadata operations, automatic error checking, and simplified file handling. Recommended for most users.

class ExifToolHelper(ExifTool):
    def __init__(self, auto_start=True, check_execute=True, check_tag_names=True, **kwargs): ...
    def get_metadata(self, files, params=None): ...
    def get_tags(self, files, tags, params=None): ...
    def set_tags(self, files, tags, params=None): ...

Helper Interface

Experimental Features

Experimental functionality for specialized use cases including batch operations, keyword management, and file-to-file tag copying.

class ExifToolAlpha(ExifToolHelper):
    def get_tag(self, filename, tag): ...
    def copy_tags(self, from_filename, to_filename): ...
    def set_keywords(self, filename, mode, keywords): ...

Experimental Features

Exception Handling

Comprehensive exception hierarchy for different error conditions with detailed error information including exit codes and command output.

class ExifToolException(Exception): ...
class ExifToolProcessStateError(ExifToolException): ...
class ExifToolExecuteException(ExifToolException): ...
class ExifToolRunning(ExifToolProcessStateError): ...
class ExifToolNotRunning(ExifToolProcessStateError): ...
class ExifToolExecuteError(ExifToolExecuteException): ...
class ExifToolOutputEmptyError(ExifToolExecuteException): ...
class ExifToolJSONInvalidError(ExifToolExecuteException): ...
class ExifToolVersionError(ExifToolException): ...
class ExifToolTagNameError(ExifToolException): ...

Exception Handling

Constants and Version

Package version and platform-specific constants for advanced configuration.

__version__ = "0.5.6"

# Platform detection
PLATFORM_WINDOWS: bool
PLATFORM_LINUX: bool

# Executable and configuration defaults
DEFAULT_EXECUTABLE = "exiftool"
DEFAULT_BLOCK_SIZE = 4096
EXIFTOOL_MINIMUM_VERSION = "12.15"

# Platform-specific constants
SW_FORCEMINIMIZE = 11  # Windows show window constant
PR_SET_PDEATHSIG = 1   # Linux process death signal constant

Types

# Type aliases for documentation
FilePath = Union[str, Path]
FileList = Union[FilePath, List[FilePath]]
TagDict = Dict[str, Any]
MetadataList = List[TagDict]
ParamsList = Optional[Union[str, List[str]]]