Skip to main content

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:

  1. Extracts the VSDX file
  2. Scans page content to find which masters are actually referenced (via USE("...") patterns)
  3. Removes unreferenced masters from masters.xml and deletes their XML files
  4. 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


Download files

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

Source Distribution

vsdx_shrinker-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

vsdx_shrinker-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file vsdx_shrinker-0.1.1.tar.gz.

File metadata

  • Download URL: vsdx_shrinker-0.1.1.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

Hashes for vsdx_shrinker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3d2b68b4b3f0dc42bb1a845458d59f4a010f7103287d4ff43e9d13fa9c66926b
MD5 0691ecf526bbbbff0d8683dc4db5ab4a
BLAKE2b-256 0994f764d1ad199d75dcd7705b54ea99b08f1612196b85db734690e0e7f3c23f

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsdx_shrinker-0.1.1.tar.gz:

Publisher: python-publish.yml on Cognitohazard/vsdx-shrinker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsdx_shrinker-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: vsdx_shrinker-0.1.1-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

Hashes for vsdx_shrinker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab2608c39eed305f387cc6706461e8b40cac0b6d5ca04a1148090be8c305b131
MD5 0cf04d60e5ab7a0898b7ee41db354f2c
BLAKE2b-256 009fbf1c6860d5bf7e7f3298f1aad8bdc2fd32d3e96f34db11a7b875c337f5c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsdx_shrinker-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on Cognitohazard/vsdx-shrinker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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