View Single Post
Old 01-20-2023, 01:57 PM   #15
isarl
Addict
isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.
 
Posts: 293
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
Quote:
Originally Posted by tatagi View Post
many thanks. yes that's the most foolproof way but at the same time very tiresome to individually edit files one at a time.
Why edit them one at a time? With something like ImageMagick you could batch-convert a bunch. I would likely do it something like this, on Linux. Assumes all your image files are jpegs (with extensions of ".jpg" or ".jpeg") and you want a max filesize of 1MB per image file:

Code:
$ unzip -d working_dir "book filename.epub"
$ cd working_dir
$ find . -iname "*.jpg" -o -iname "*.jpeg" -execdir mogrify -define jpeg:extent=1MB '{}' ';'
$ zip -r "book filename.compressed.epub" .
$ mv "book filename.compressed.epub" ..
$ cd ..
$ rm -rf working_dir
Note that ImageMagick's “mogrify” command modifies files in-place. This is (potentially) a DESTRUCTIVE operation!

Last edited by isarl; 01-20-2023 at 02:02 PM. Reason: modify code to use a different filename for the new book, so the mv operation doesn't overwrite the old one.
isarl is offline   Reply With Quote