mirror of
https://github.com/hendricius/the-sourdough-framework
synced 2025-11-09 04:31:11 -06:00
Reduce colour ebook size
Reduce picture quality as the kindle app on the phone has a 30 MByte limit
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -41,3 +41,4 @@ book/epub/
|
|||||||
book/book-epub/
|
book/book-epub/
|
||||||
book/bw-book-epub/*
|
book/bw-book-epub/*
|
||||||
book/release/*
|
book/release/*
|
||||||
|
book/low-res-book-epub/*
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ CONVERT_PIC := convert
|
|||||||
REDUCE_PIC := -resize '800x800>' \
|
REDUCE_PIC := -resize '800x800>' \
|
||||||
-strip -interlace Plane -gaussian-blur 0.05 -quality 85\% \
|
-strip -interlace Plane -gaussian-blur 0.05 -quality 85\% \
|
||||||
-set colorspace Gray -separate -evaluate-sequence Mean
|
-set colorspace Gray -separate -evaluate-sequence Mean
|
||||||
|
REDUCE_PIC_COLOR := -quality 80\%
|
||||||
RSYNC := rsync -au --exclude 'book.epub' --exclude '*.jpg' --exclude '*.png'
|
RSYNC := rsync -au --exclude 'book.epub' --exclude '*.jpg' --exclude '*.png'
|
||||||
GIT := git --no-pager
|
GIT := git --no-pager
|
||||||
SPELL_CHECK := hunspell -t -l -d en_US
|
SPELL_CHECK := hunspell -t -l -d en_US
|
||||||
@@ -53,6 +54,10 @@ images += $(foreach directory, $(chapters), $(wildcard $(directory)/*/*.png))
|
|||||||
# images to lower resolution and greyscale
|
# images to lower resolution and greyscale
|
||||||
bw_images := $(addprefix bw-book-epub/OEBPS/, $(images))
|
bw_images := $(addprefix bw-book-epub/OEBPS/, $(images))
|
||||||
|
|
||||||
|
# Reduced ebook, we will just re-zip directory after converting the
|
||||||
|
# images to lower resolution
|
||||||
|
low_res_images := $(addprefix low-res-book-epub/OEBPS/, $(images))
|
||||||
|
|
||||||
src_all := $(src_tex) $(src_figures) $(src_tables) $(images)
|
src_all := $(src_tex) $(src_figures) $(src_tables) $(images)
|
||||||
|
|
||||||
ebook_src := $(src_all) tex4ebook.cfg book.mk4 book-ebook.css
|
ebook_src := $(src_all) tex4ebook.cfg book.mk4 book-ebook.css
|
||||||
@@ -101,7 +106,7 @@ book_serif/book.pdf: $(src_all)
|
|||||||
book_sans_serif/book_sans_serif.pdf: $(src_all)
|
book_sans_serif/book_sans_serif.pdf: $(src_all)
|
||||||
$(LATEX) -output-directory=book_sans_serif book_sans_serif.tex
|
$(LATEX) -output-directory=book_sans_serif book_sans_serif.tex
|
||||||
|
|
||||||
.PHONY: copy_ebook_files
|
.PHONY: copy_ebook_files copy_ebook_files_cl
|
||||||
|
|
||||||
epub/%.epub: %.tex $(ebook_src) cover/cover-page.xbb
|
epub/%.epub: %.tex $(ebook_src) cover/cover-page.xbb
|
||||||
$(EBOOK) $<
|
$(EBOOK) $<
|
||||||
@@ -109,6 +114,9 @@ epub/%.epub: %.tex $(ebook_src) cover/cover-page.xbb
|
|||||||
copy_ebook_files: build_ebook
|
copy_ebook_files: build_ebook
|
||||||
$(RSYNC) book-epub/ bw-book-epub/
|
$(RSYNC) book-epub/ bw-book-epub/
|
||||||
|
|
||||||
|
copy_ebook_files_cl: build_ebook
|
||||||
|
$(RSYNC) book-epub/ low-res-book-epub/
|
||||||
|
|
||||||
# We do not convert SVG to B&W or lower res for now as they are super small
|
# We do not convert SVG to B&W or lower res for now as they are super small
|
||||||
# anyway
|
# anyway
|
||||||
bw-book-epub/OEBPS/%.jpg: %.jpg
|
bw-book-epub/OEBPS/%.jpg: %.jpg
|
||||||
@@ -119,10 +127,22 @@ bw-book-epub/OEBPS/%.png: %.png
|
|||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
$(CONVERT_PIC) $< $(REDUCE_PIC) $@
|
$(CONVERT_PIC) $< $(REDUCE_PIC) $@
|
||||||
|
|
||||||
|
low-res-book-epub/OEBPS/%.jpg: %.jpg
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(CONVERT_PIC) $< $(REDUCE_PIC_COLOR) $@
|
||||||
|
|
||||||
|
low-res-book-epub/OEBPS/%.png: %.png
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(CONVERT_PIC) $< $(REDUCE_PIC_COLOR) $@
|
||||||
|
|
||||||
epub/bw_book.epub: copy_ebook_files $(bw_images)
|
epub/bw_book.epub: copy_ebook_files $(bw_images)
|
||||||
cd bw-book-epub; zip -q0X ../epub/bw_book.epub mimetype
|
cd bw-book-epub; zip -q0X ../epub/bw_book.epub mimetype
|
||||||
cd bw-book-epub; zip -q9XrD ../epub/bw_book.epub ./
|
cd bw-book-epub; zip -q9XrD ../epub/bw_book.epub ./
|
||||||
|
|
||||||
|
epub/low_res_book.epub: copy_ebook_files_cl $(low_res_images)
|
||||||
|
cd low-res-book-epub; zip -q0X ../epub/low_res_book.epub mimetype
|
||||||
|
cd low-res-book-epub; zip -q9XrD ../epub/low_res_book.epub ./
|
||||||
|
|
||||||
# Now with the rules
|
# Now with the rules
|
||||||
# Expected usual rules first
|
# Expected usual rules first
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
@@ -200,6 +220,8 @@ build_ebook: epub/book.epub
|
|||||||
|
|
||||||
build_bw_ebook: epub/bw_book.epub
|
build_bw_ebook: epub/bw_book.epub
|
||||||
|
|
||||||
|
build_low_res_ebook: epub/low_res_book.epub
|
||||||
|
|
||||||
.PHONY: export_figures check tex-check spell-check
|
.PHONY: export_figures check tex-check spell-check
|
||||||
# Requires that you have docker running on your computer.
|
# Requires that you have docker running on your computer.
|
||||||
export_figures: build_pdf $(tgt_figures)
|
export_figures: build_pdf $(tgt_figures)
|
||||||
@@ -276,10 +298,11 @@ bake: release_serif release_sans_serif release_booklet
|
|||||||
release:
|
release:
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
|
|
||||||
release_serif: build_serif_pdf build_ebook build_bw_ebook | release
|
release_serif: build_serif_pdf build_ebook build_bw_ebook build_low_res_ebook | release
|
||||||
cp book_serif/book.pdf release/TheBreadCode-The-Sourdough-Framework.pdf
|
cp book_serif/book.pdf release/TheBreadCode-The-Sourdough-Framework.pdf
|
||||||
cp epub/book.epub release/TheBreadCode-The-Sourdough-Framework.epub
|
cp epub/book.epub release/TheBreadCode-The-Sourdough-Framework.epub
|
||||||
cp epub/bw_book.epub release/TheBreadCode-The-Sourdough-Framework-black-and-white.epub
|
cp epub/bw_book.epub release/TheBreadCode-The-Sourdough-Framework-black-and-white.epub
|
||||||
|
cp epub/low_res_book.epub release/TheBreadCode-The-Sourdough-Framework-reduced-size.epub
|
||||||
|
|
||||||
release_sans_serif: build_sans_serif_pdf | release
|
release_sans_serif: build_sans_serif_pdf | release
|
||||||
cp book_sans_serif/book_sans_serif.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf
|
cp book_sans_serif/book_sans_serif.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf
|
||||||
|
|||||||
Reference in New Issue
Block a user