You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
pymupdf is currently largest package in our app, responsible for about 54Mb of our Docker image.
Describe the solution you'd like
Could the package be made smaller? For example, could some features be made opt-in (e.g. pymupdf['lite'] or something).
Describe alternatives you've considered
Not that I could think of.
The largest size contributors by far are the MuPDF binaries - which represent the complete functionality of MuPDF.
When we generate these binaries, we already today use a number of size reducing options and e.g. exclude fonts that we consider unnecessary.
So your question is probably better directed to the MuPDF team from this perspective.
Apart from this, re-configuring / segmenting a package like pymupdf is a very, very significant effort, for which I fail to see an economical justification.
What you could try is using a compressor for binary executable code like upx which is available for most platforms. It will compress executables, mostly achieving size reduction of 50% or more. The respective code is decompressed when loaded for use.
Here is an example run on Windows:
c:/upx/upx -9 *.*
upx: __pycache__: IOException: is a directory -- skipped
upx: _apply_pages.py: UnknownExecutableFormatException
upx: _build.py: IOException: file is too small -- skipped
190464 -> 70656 37.10% win64/pe _extra.pyd
102912 -> 33280 32.34% win64/pe _features.pyd
upx: _features_build.py: IOException: file is too small -- skipped
11894784 -> 2321920 19.52% win64/pe _mupdf.pyd
145408 -> 50688 34.86% win64/pe _pro.pyd
upx: _wxcolors.py: UnknownExecutableFormatException
upx: extra.py: UnknownExecutableFormatException
upx: features.py: UnknownExecutableFormatException
upx: layout: IOException: is a directory -- skipped
upx: mupdf-devel: IOException: is a directory -- skipped
upx: mupdf.py: UnknownExecutableFormatException
Compressing mupdfcpp64.dll [win64/pe, NRV2E/9]
24855552 -> 12983808 52.24% win64/pe mupdfcpp64.dll..] 44.3% /
upx: pro.py: UnknownExecutableFormatException********************] 49.6% |
upx: pymupdf.py: IOException: file is too small -- skipped
13202432 -> 5680128 43.02% win64/pe sodochandler.dll
upx: table.py: UnknownExecutableFormatException
upx: utils.py: UnknownExecutableFormatException
-------------------- ------ ----------- -----------
50391552 -> 21140480 41.95% [ 6 files ]
Packed 6 files.
It brings down the original 51.5 MB to 23.6 MB - automatically skipping files that are not eligible.
When an application uses PyMuPDF, the binaries are decompressed when loaded in memory.
This can be lead to notably longer durations of import statements.
Activity
JorjMcKie commentedon Nov 12, 2025
The largest size contributors by far are the MuPDF binaries - which represent the complete functionality of MuPDF.
When we generate these binaries, we already today use a number of size reducing options and e.g. exclude fonts that we consider unnecessary.
So your question is probably better directed to the MuPDF team from this perspective.
Apart from this, re-configuring / segmenting a package like pymupdf is a very, very significant effort, for which I fail to see an economical justification.
JorjMcKie commentedon Nov 12, 2025
What you could try is using a compressor for binary executable code like
upxwhich is available for most platforms. It will compress executables, mostly achieving size reduction of 50% or more. The respective code is decompressed when loaded for use.Here is an example run on Windows:
It brings down the original 51.5 MB to 23.6 MB - automatically skipping files that are not eligible.
When an application uses PyMuPDF, the binaries are decompressed when loaded in memory.
This can be lead to notably longer durations of
importstatements.