diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..384eee5 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +NAME=photos2pdf +DESTDIR= +PREFIX=/usr +INSTALL=install + +BINDIR=$(PREFIX)/bin +LIBDIR=/var/lib/$(NAME) +TEMPLATEDIR=$(LIBDIR)/template + +.PHONY: all install-bin install-template install + +all: + @echo "Use \"sudo $(MAKE) install\" to install $(NAME)" + +install-bin: + $(INSTALL) -d -m 0755 "$(BINDIR)" + $(INSTALL) -m 0755 "$(NAME)" "$(BINDIR)/$(NAME)" + +install-template: + $(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)" + $(INSTALL) -d -m 0755 "$(DESTDIR)$(TEMPLATEDIR)" + tar cf - -C template . | (cd "$(DESTDIR)$(TEMPLATEDIR)" && tar xf -) + +install: install-bin install-template diff --git a/run.sh b/photos2pdf similarity index 96% rename from run.sh rename to photos2pdf index 4f1a6ea..c51b184 100755 --- a/run.sh +++ b/photos2pdf @@ -41,6 +41,9 @@ offset="1cm 3cm" # Factor to scale image by before placing in page scale=0.75 +# PDF backdrop template directory +templatedir=/var/lib/photos2pdf/templates + # Filename of complete result PDF result="pdf/result.pdf" @@ -77,7 +80,7 @@ if [[ -z $dir ]] ; then error "Usage: $0 DIR" fi -origdir=$(dirname "$(readlink -f "$dir")") +origdir=$(readlink -f "$dir") if [[ ! -d $origdir ]] ; then error "Directory not found: $dir ($origdir)" @@ -286,17 +289,17 @@ for png in "out/"*.png ; do rv=1 continue elif [[ $width -gt $height ]] ; then - backdrop=template/a4paper/landscape.pdf + backdrop="$templatedir/a4paper/landscape.pdf" jam_landscape=--landscape else - backdrop=template/a4paper/portrait.pdf + backdrop="$templatedir/a4paper/portrait.pdf" jam_landscape=--no-landscape fi base=$(basename "$png" .png) - pdf=tmp/$base.pdf - jammed=tmp/$base-pdfjam.pdf - backdropped=tmp/$base.backdropped.pdf + pdf="$tmpdir/$base.pdf" + jammed="$tmpdir/$base-pdfjam.pdf" + backdropped="$tmpdir/$base.backdropped.pdf" if ! convert "$png" "$pdf" ; then warning "Could not convert \"$png\" to PDF; skipped."