Fabian42 / bash_scripts

Contains various bash scripts that I have written mainly for myself.
The Unlicense
5 stars 0 forks source link

Create PDF from images under size #40

Open Fabian42 opened 2 years ago

Fabian42 commented 2 years ago

Write a script to combine multiple images into one PDF file, properly scaled and under a given file size. Probably not to be integrated into shrink, because input and output have different formats. Old version:

for i in {2..99999}; do
 echo "trying 1/$i…"
 convert conti_1.png conti_2.png -scale "$(qalc -t -s "maxdeci 0" "100/$i")%" -page "A4" conti.pdf
 size=$(du -b conti.pdf | awk '{print $1}')
 echo "($size bytes)"
 if (( $size <= 15728640 )); then
  break
 fi
 rm conti.pdf
done