{"library":"pyexiftool","title":"PyExifTool","description":"PyExifTool provides a convenient Python interface to Phil Harvey's ExifTool, a powerful command-line application for reading, writing, and editing metadata in a wide variety of file formats. The current version is 0.5.6, and it maintains an active release cadence with new features and improvements.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pyexiftool"],"cli":null},"imports":["from pyexiftool import ExifTool","from pyexiftool import ExifToolHelper"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom pyexiftool import ExifTool\n\n# IMPORTANT: Ensure the 'exiftool' command-line utility is installed\n# and accessible on your system PATH.\n# For Debian/Ubuntu: sudo apt-get install libimage-exiftool-perl\n# For macOS: brew install exiftool\n# More info: https://exiftool.org/ \n\n# Create a dummy image file for demonstration if it doesn't exist\nimage_file = \"example.jpg\"\nif not os.path.exists(image_file):\n    with open(image_file, \"w\") as f:\n        f.write(\"Simulated JPEG content\\n\")\n    print(f\"Created dummy file: {image_file}. Replace with a real image for meaningful EXIF data.\")\n\ntry:\n    # Use ExifTool as a context manager to ensure proper process handling\n    with ExifTool() as et:\n        # Read all metadata from the image file\n        metadata = et.get_metadata(image_file)\n        print(f\"\\nMetadata for {image_file}:\")\n        for tag, value in metadata.items():\n            print(f\"  {tag}: {value}\")\n\n        # Example of writing metadata (uncomment and use a real image if needed)\n        # For writing, ensure the image_file is a real image and you have write permissions.\n        # new_tags = {\"Exif.Image.Artist\": \"Python Bot\", \"Exif.Image.Copyright\": \"2023 Example Corp\"}\n        # et.set_tags(new_tags, [image_file])\n        # print(f\"\\nUpdated metadata for {image_file}\")\n        # updated_metadata = et.get_metadata(image_file)\n        # print(\"Updated Artist:\", updated_metadata.get(\"Exif.Image.Artist\"))\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure 'exiftool' is installed and your image file path is correct.\")\nfinally:\n    # Clean up the dummy file if it was created\n    if os.path.exists(image_file) and os.path.getsize(image_file) == len(\"Simulated JPEG content\\n\"):\n        os.remove(image_file)\n        print(f\"Cleaned up dummy file: {image_file}\")","lang":"python","description":"This quickstart demonstrates how to instantiate ExifTool using a context manager and read metadata from an image file. It includes a fallback to create a dummy file for immediate execution, but real EXIF data requires a valid image. It also highlights the requirement for the `exiftool` command-line utility.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}