Calc- How to compress all images in a file

I have over 300 images that need to be compressed the same way.
When you export to pdf you have this option.
I need the same thing for an export to ods or xls or a way to easily multiselect and compress all images in a file

On my Linux system I have a collection of programs called “ImageMagick”. One of the programs is called “mogrify”: ImageMagick – Command-line Tools: Mogrify

Copy my spreadsheet to a test directory and go to that directory.

mkdir /tmp/test
mv embedded_Pics.ods /tmp/test
cd /tmp/test

Unzip the office document and go to the Pictures folder

unzip embedded_Pics.ods
cd Pictures

Call mogrify to resize each file to 50% and rebuild the zip container.

for f in $(ls);do mogrify -resize 50% $f;done
cd ..
zip --freshen embedded_Pics.ods

The resulting document has all pictures in place with resulutions visibly decreased.

1 Like

Thank you, all steps work except the last one. No error and the pictures folder is significantly smaller however the ods file is the same size on Linux Mint.

cd …
moves from the Pictures directory back to the parent directory where the ods file resides.
zip --freshen embedded_Pics.ods
updates the zip container with the modified files.
If there is no error message, the operation should have been executed well. May be you can see the change after refreshing your file manager (usually key F5) ?

P.S. output messages from the zip command:

$ zip --freshen embedded_Pictures.ods.odt 
freshening: Pictures/1000000000000FC000000BD00302A5DA16F78E7B.jpg (deflated 0%)
freshening: Pictures/1000000000000BD000000FC00F6E6955EB7C4999.jpg (deflated 0%)
freshening: Pictures/1000000000000BD000000FC02392FE7684474169.jpg (deflated 0%)
freshening: Pictures/1000000100000536000002EE262AC6EB61B9A52F.png (deflated 0%)
freshening: Pictures/1000000000000BD000000FC0E987D30CA9DCBD91.jpg (deflated 0%)

I retried it this time it worked, I thank you

You might try this extension: PixCompress which should do what you’re looking for.

It might , however I can’t locate it after installing and can’t find instructions on how to use it

On my system (LinuxMint 20.3, LibreOffice 7.4) there’s an entry as Tools > Minimize pictures (at the bottom of the menu).

Edit: as the original size of the images will be definitively lost,make sure to work on a copy of the original document!

libreoffice 7.4.5.1 on windows 11 , no such entry exists or under add ons. It does show installed in extension manager

menu:Tools>Minimize pictures…
You can also call the installed macro directly via Tools>Macros>Run>PixCompress>Pixcompress>Main

I receive
error - Basic runtime error property or method not found
at
oImages = oDoc.getDrawPage()

It is written for Writer.