Skip to content

Instantly share code, notes, and snippets.

@chrodriguez
Last active August 27, 2019 22:43
Show Gist options
  • Save chrodriguez/4506ab66490b97fc3eb6bbb68fa1716a to your computer and use it in GitHub Desktop.
Save chrodriguez/4506ab66490b97fc3eb6bbb68fa1716a to your computer and use it in GitHub Desktop.
Como crear un mosaico de imagenes en un PDF
DPI=300
# Como las dimensiones del A3 son 16.5x11.7 pulgadas, para poder hacer esto en shell:
X=165
Y=117
ANCHO=$(( $X*$DPI/10 ))
AlTO=$(( $Y*$DPI/10 ))
COUNT=0
FILES=""
DONE=0
SPACES=50
generate_multi() {
[ -z "$FILES" ] && echo "no input files. Done!" && return
if [ ! -e multi/multi-$(printf "%03d" $DONE).jpg ]; then
montage $FILES -tile 2x2 -mode concatenate -geometry +$SPACES+$SPACES multi/multi-$(printf "%03d" $DONE).jpg
else
echo skip multi/multi-$(printf "%03d" $DONE).jpg
fi
DONE=$(( $DONE + 1 ))
}
for i in *jpg; do
COUNT=$(( $COUNT + 1 ))
FILES="$FILES $i"
if [ $COUNT -eq 4 ]; then
COUNT=0
generate_multi
FILES=""
fi
done
generate_multi
for i in multi/*jpg; do
convert $i -resize ${ANCHO}x${ALTO} -extent ${ANCHO}x${ALTO} -gravity center -units PixelsPerInch -density $DPIx$DPI multi/$(basename $i .jpg).pdf
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment