Overview
DMeta is an open source Python package that removes metadata of Microsoft Office files and image files.
| PyPI Counter |
|
| Github Stars |
|
| Branch |
main |
dev |
| CI |
|
|
| Code Quality |
 |
 |
Installation
PyPI
Source code
Usage
In Python
⚠️ Use in_place to apply the changes directly to the original file.
⚠️in_place flag is False by default.
import os
from dmeta.functions import clear
DOCX_FILE_PATH = os.path.join(os.getcwd(), "sample.docx")
clear(DOCX_FILE_PATH, in_place=True)
import os
from dmeta.functions import clear_file
FILE_PATH = os.path.join(os.getcwd(), "photo.png")
clear_file(FILE_PATH, in_place=True)
from dmeta.functions import clear_all
clear_all()
import os
from dmeta.functions import update
CONFIG_FILE_PATH = os.path.join(os.getcwd(), "config.json")
DOCX_FILE_PATH = os.path.join(os.getcwd(), "sample.pptx")
update(CONFIG_FILE_PATH, DOCX_FILE_PATH, in_place=True)
import os
from dmeta.functions import update_all
CONFIG_FILE_PATH = os.path.join(os.getcwd(), "config.json")
update_all(CONFIG_FILE_PATH)
CLI
⚠️ You can use dmeta or python -m dmeta to run this program
⚠️ Use --inplace to apply the changes directly to the original file.
dmeta --clear "./test_a.docx" --inplace
dmeta --clear "./photo.png" --inplace
dmeta --clear-all
dmeta --update "./test_a.xlsx" --config "./config.json" --inplace
dmeta --update-all --config "./config.json"
Version
dmeta -v
dmeta --version
Info
dmeta --info
To ensure that no Microsoft Office files ever enter your repo with embedded metadata, you can use Dmeta’s built-in pre-commit hooks.
1. Install the pre-commit framework
If you don’t already have it:
pip install pre-commit
In your project root, create or update .pre-commit-config.yaml:
repos:
- repo: https://github.com/openscilab/dmeta.git
rev: v0.5 # minimum v0.4 or commit SHA
hooks:
- id: clear-metadata
rev: must exactly match the minimum tag supporting pre-commit hooks or the commit SHA where the targetted .pre-commit-hooks.yaml exists.
3. Install the hook
pre-commit install # or pre_commit install (in windows)
Now, every time you git commit, Dmeta will automatically clear metadata from any supported files in-place.
⚠️ Important: Clean Before You Commit
Do not stage or add Microsoft Office files before removing their metadata.
If you run git add on Office files that still contain embedded metadata, the pre-commit hook will attempt to clean them in-place, which modifies the files after they’ve been staged. As a result, Git will block the commit because the content has changed mid-process.
✅ Suggested Correct Workflow
-
Let the hook run automatically on earlier commits that didn’t add Office files, or run it manually. To do manually you can run pre-commit run clear-metadata --all-files
-
Then:
git add <cleaned-files>
git commit -m "Your message"
Supported files
| File format |
support |
| Microsoft Word (.docx) |
✅ |
| Microsoft PowerPoint (.pptx) |
✅ |
| Microsoft Excel (.xlsx) |
✅ |
| PNG (.png) |
✅ |
| JPEG (.jpg, .jpeg) |
✅ |
| GIF (.gif) |
✅ |
Issues & bug reports
Just fill an issue and describe it. We’ll check it ASAP! or send an email to [email protected].
- Please complete the issue template
You can also join our discord server
Acknowledgments
Python Software Foundation (PSF) granted DMeta library partially for version(s) 0.4, 0.5.
PSF is the organization behind Python. Their mission is to promote, protect, and advance the Python programming language and to support and facilitate the growth of a diverse and international community of Python programmers.

Show your support
Star this repo
Give a ⭐️ if this project helped you!
Donate to our project
If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) .

评论