osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/31961 )
Change subject: build/Makefile.common: shrink pdfs before publish ...................................................................... build/Makefile.common: shrink pdfs before publish Closes: SYS#6380 Change-Id: I7c01b1cb1a0e7de385359671461a0ad142dfa5ad --- M build/Makefile.common.inc A build/shrink-pdfs.sh 2 files changed, 46 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/61/31961/1 diff --git a/build/Makefile.common.inc b/build/Makefile.common.inc index bdc3817..9e79621 100644 --- a/build/Makefile.common.inc +++ b/build/Makefile.common.inc @@ -9,8 +9,9 @@ SSH_COMMAND = ssh -o 'UserKnownHostsFile=$(OSMO_GSM_MANUALS_DIR)/build/known_hosts' -p 48 UPLOAD_PATH ?= generic@sysmocom-downloads:documents SYMLINKS = common build -CLEAN_FILES += $(SYMLINKS) +CLEAN_FILES += $(SYMLINKS) $(SHRINK_MARKER) PDF_FILES = $(patsubst %.adoc,%.pdf,$(ASCIIDOC)) $(patsubst %.xml,%.pdf,$(VTY_REFERENCE)) +SHRINK_MARKER = generated/.pdf_shrink_marker PUBLISH_REF ?= master PUBLISH_TEMPDIR = _publish_tmpdir @@ -20,12 +21,17 @@ $(SYMLINKS): ln -s $(OSMO_GSM_MANUALS_DIR)/$@ $@ +# Reduce pdf size by storing the embedded images with less quality (SYS#6380) +shrink: $(SHRINK_MARKER) +$(SHRINK_MARKER): $(UPLOAD_FILES) + build/shrink-pdfs.sh $(UPLOAD_FILES) + # Publish to $UPLOAD_PATH -upload: $(UPLOAD_FILES) +upload: shrink rsync -avz $(UPLOAD_FILES) $(UPLOAD_PATH)/ # Publish to https://ftp.osmocom.org/docs/ -publish: $(UPLOAD_FILES) +publish: shrink [ -n "$(OSMO_REPOSITORY)" ] || exit 1 rm -rf "$(PUBLISH_TEMPDIR)" mkdir -p "$(PUBLISH_TEMPDIR)/$(OSMO_REPOSITORY)/$(PUBLISH_REF)" diff --git a/build/shrink-pdfs.sh b/build/shrink-pdfs.sh new file mode 100755 index 0000000..a919ac3 --- /dev/null +++ b/build/shrink-pdfs.sh @@ -0,0 +1,27 @@ +#!/bin/sh -e +# Reduce pdf size by storing the embedded images with less quality (SYS#6380) +# usage: shrink-pdfs.sh first.pdf [second.pdf [...]] +mkdir -p generated + +for i in $@; do + out="generated/shrink_temp.pdf" + ps2pdf -dPDFSETTINGS=/ebook "$i" "$out" + + size_old=$(du "$i" | cut -f1) + size_old_h=$(du -h "$i" | cut -f1) + size_new=$(du "$out" | cut -f1) + size_new_h=$(du -h "$out" | cut -f1) + + if [ "$size_new" -lt "$size_old" ]; then + echo "* $i: $size_new_h (shrunk from $size_old_h)" + mv "$out" "$i" + else + echo "* $i: $size_old_h" + rm "$out" + fi +done + +# Add a marker so the Makefile knows that the shrink script ran. The generated +# dir is already in the gitignore files of repositories using osmo-gsm-manuals, +# so put it there. +touch generated/.pdf_shrink_marker -- To view, visit https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/31961 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Change-Id: I7c01b1cb1a0e7de385359671461a0ad142dfa5ad Gerrit-Change-Number: 31961 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osm...@sysmocom.de> Gerrit-MessageType: newchange