Compress an Office file
Is the .docx, .xlsx or .pptx with photos inside too heavy for email or the portal? Here only the images are recompressed and everything else stays identical byte for byte: the document text cannot change. The file never leaves your browser.
Where the weight is, and why only the images are touched
A modern Office file (.docx, .xlsx, .pptx) is really a ZIP archive with many parts inside: the text, the formatting, and the images, which are files of their own. When a document weighs tens of MB, the weight is almost always in the high-resolution photos stuffed inside (a phone photo alone weighs more than a thousand pages of text). Here only those are recompressed: all the rest of the document is copied exactly as it was, so the text, tables and formatting cannot break.
Why it cannot break
It is the same idea as Clean up an Office file: the parts not touched are not rebuilt, they are copied still compressed, byte for byte. And the images are recompressed in their own format (a JPEG stays JPEG, a PNG stays PNG): so the file names, internal links and type map stay intact. Changing an image format would be exactly what makes «Word found a problem» appear.
What happens to the images
Each photo is shrunk (if huge) and recompressed at a lower but still good quality for reading and printing. You choose the level: «for the screen» makes the lightest file, «good» is the recommended compromise, «high» touches little. A rule you do not see: if recompressing an image gains nothing (it was already light, or a small logo), it is left as it was, so the file never gets worse.
How it is checked to be right
The file produced is read back by the programs that truly read Office (python-docx, openpyxl, python-pptx): the text must be identical to the original, otherwise something broke. Also the archive must pass the integrity check (unzip -t), the number of images must stay the same, and on a file with heavy images the weight must really drop. A file that opens but with changed text is the worst fault, and this test catches it.
What it does not do
It does not touch the text, the formatting, the tables: only the images. It does not decode vector formats (EMF, WMF, the charts drawn by Office): those it leaves as they were and says so. If the file is password-protected remove it first, with the program it was saved with. To remove hidden data (author, revisions) there is Clean up an Office file, and for a PDF instead of an Office file there is Compress PDF.