Remove unused master shapes from Visio (.vsdx) files to dramatically reduce file size
Project description
vsdx-shrinker
Remove unused master shapes from Visio (.vsdx) files to dramatically reduce file size.
The Problem
Visio files can become bloated when you copy-paste content from PDFs, vector graphics, or other sources. Each paste operation can create "master shapes" that remain in the file even after you delete the visible content. These orphaned masters can make your file 10x larger than necessary.
How It Works
VSDX files are ZIP archives containing XML. This tool:
- Extracts the VSDX file
- Scans page content to find which masters are actually referenced (via
USE("...")patterns) - Removes unreferenced masters from
masters.xmland deletes their XML files - Repacks the cleaned archive
Installation
pip install vsdx-shrinker
Or with uv:
uv tool install vsdx-shrinker
Usage
Command Line
Shrink a file (creates backup):
vsdx-shrinker diagram.vsdx
Shrink to a new file:
vsdx-shrinker diagram.vsdx -o diagram_small.vsdx
Analyze without modifying:
vsdx-shrinker diagram.vsdx --analyze
Python API
from vsdx_shrinker import shrink_vsdx, analyze_vsdx
# Analyze a file
result = analyze_vsdx("diagram.vsdx")
print(f"Can save {result['potential_savings_mb']} MB")
# Shrink a file
result = shrink_vsdx("diagram.vsdx", output_path="diagram_small.vsdx")
print(f"Reduced by {result['reduction_percent']}%")
CLI Options
usage: vsdx-shrinker [-h] [-o OUTPUT] [--no-backup] [--analyze] [-q] [--version] input
positional arguments:
input Input .vsdx file path
options:
-h, --help show this help message and exit
-o, --output OUTPUT Output file path (default: overwrite input with backup)
--no-backup Do not create backup when overwriting input file
--analyze Only analyze the file, do not modify
-q, --quiet Suppress output except errors
--version show program's version number and exit
Example Output
$ vsdx-shrinker presentation.vsdx --analyze
Analysis of: presentation.vsdx
Total masters: 244
Used masters: 6
Unused masters: 238
Potential savings: 79.17 MB
$ vsdx-shrinker presentation.vsdx -o presentation_clean.vsdx
Shrunk: presentation.vsdx
Original size: 14.8 MB
New size: 1.6 MB
Reduction: 13.2 MB (89.2%)
Masters removed: 238
Output: presentation_clean.vsdx
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vsdx_shrinker-0.1.0.tar.gz.
File metadata
- Download URL: vsdx_shrinker-0.1.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ff9b77937cc215f7b502e4ec24bfaec57be57b151d747b6b02882b028219756
|
|
| MD5 |
cac63ca34450a26de7b223d44fb91b18
|
|
| BLAKE2b-256 |
14541bfe2b6843f635184d2b5675c628c36a1b6dcecc7618d751ef9139c49ad9
|
Provenance
The following attestation bundles were made for vsdx_shrinker-0.1.0.tar.gz:
Publisher:
python-publish.yml on Cognitohazard/vsdx-shrinker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vsdx_shrinker-0.1.0.tar.gz -
Subject digest:
0ff9b77937cc215f7b502e4ec24bfaec57be57b151d747b6b02882b028219756 - Sigstore transparency entry: 868974839
- Sigstore integration time:
-
Permalink:
Cognitohazard/vsdx-shrinker@64d9faa1eab7bc5d5c0018c52c47c9f4719c5c13 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Cognitohazard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64d9faa1eab7bc5d5c0018c52c47c9f4719c5c13 -
Trigger Event:
release
-
Statement type:
File details
Details for the file vsdx_shrinker-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vsdx_shrinker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2e9c6f453cb7a3b08d94dca28b0102ab4715be88cfbd5e05ce7a9c48735b7d2
|
|
| MD5 |
92093dd93a066e981e67e2e78b972fce
|
|
| BLAKE2b-256 |
847bc73518dc6c611570c619d44a5ad75fabf8066f8e34abc94cc06cdaffa491
|
Provenance
The following attestation bundles were made for vsdx_shrinker-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on Cognitohazard/vsdx-shrinker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vsdx_shrinker-0.1.0-py3-none-any.whl -
Subject digest:
a2e9c6f453cb7a3b08d94dca28b0102ab4715be88cfbd5e05ce7a9c48735b7d2 - Sigstore transparency entry: 868974841
- Sigstore integration time:
-
Permalink:
Cognitohazard/vsdx-shrinker@64d9faa1eab7bc5d5c0018c52c47c9f4719c5c13 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Cognitohazard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64d9faa1eab7bc5d5c0018c52c47c9f4719c5c13 -
Trigger Event:
release
-
Statement type: