Any method to compress all images inside any document?

I tried to write a macro with base or a plugin called pixcompress, but no luck, how to compress all images and convert to JPG or PNG, and play with their properties without modify LibreOffice variables?

edit1: time ago I pasted 100 images of 100 kb each image, but for some reason writer size was 1GB, no sure why.

Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 7370d4be9e3cf6031a51beef54ff3bda878e3fac
CPU threads: 12; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Vulkan; VCL: win
Locale: es-PE (es_PE); UI: en-US
Calc: threaded

with base?
.
If base means the database component of LibreOffice Base, things will heavily depend on the database you use… So more data needed.
.
If you wish to use BASIC as programming language you can access components of LibreOffice-files. But the question is: How to do the conversions/compression etc. Self coded routines / external libraries or do you expect to find everything in LibreOffice? Maybe python with pillow is an easier approach.
.
As a starter, without the conversion look at another thread currently active on the topic of replacing images: