Convert ODG to common raster and vector image formats

Makefile
# ============================================
# Purpose: Convert Open Document Graphics to 
# common raster and vector image formats.
# ============================================
 
### Source files
EXT := odg
SRC := $(wildcard *.$(EXT))
 
### Target files
PDF := $(patsubst %.$(EXT),%.pdf,$(SRC))
SVG := $(patsubst %.$(EXT),%.svg,$(SRC))
EPS := $(patsubst %.$(EXT),%.eps,$(SRC))
PNG := $(patsubst %.$(EXT),%.png,$(SRC))
GIF := $(patsubst %.$(EXT),%.gif,$(SRC))
WMF := $(patsubst %.$(EXT),%.wmf,$(SRC))
JPG := $(patsubst %.$(EXT),%.jpg,$(SRC))
EMF := $(patsubst %.$(EXT),%.emf,$(SRC))
BMP := $(patsubst %.$(EXT),%.bmp,$(SRC))
 
### Dependencies
pdf: $(PDF)
svg: $(SVG)
eps: $(EPS)
png: $(PNG)
gif: $(GIF)
wmf: $(WMF)
jpg: $(JPG)
emf: $(EMF)
bmp: $(BMP)
 
raster: png gif jpg bmp
vector: pdf svg eps wmf wmf
 
### Rules for raster images
 
A4_300DPI := -e 'Width=2480' -e 'Height=3508' -e 'Resolution=300'
A4_200DPI := -e 'Width=1654' -e 'Height=2338' -e 'Resolution=200'
A4_150DPI := -e 'Width=1240' -e 'Height=1754' -e 'Resolution=150'
 
# Choose desired resolution here
OPTIONS := $(A4_300DPI)
#OPTIONS := $(A4_200DPI)
#OPTIONS := $(A4_150DPI)
 
%.png: %.$(EXT)
	unoconv --doctype=graphics --format=png $(OPTIONS) $<
	mogrify -trim $@
 
%.gif: %.$(EXT)
	unoconv --doctype=graphics --format=gif $(OPTIONS) $<
	mogrify -trim $@
 
%.jpg: %.$(EXT)
	unoconv --doctype=graphics --format=jpg $(OPTIONS) -e 'Quality=85' $<
	mogrify -trim $@
 
%.bmp: %.$(EXT)
	unoconv --doctype=graphics --format=bmp $(OPTIONS) $<
	mogrify -trim $@
 
### Rules for vector images
%.pdf: %.$(EXT)
	unoconv --doctype=graphics --format=pdf -o /tmp/$@ $<
	pdfcrop /tmp/$@ $@
 
%.svg: %.$(EXT)
	unoconv --doctype=graphics --format=svg $<
 
%.eps: %.$(EXT)
	unoconv --doctype=graphics --format=eps -o /tmp/$@ $<
	epstool --bbox --copy /tmp/$@ $@
 
%.wmf: %.$(EXT)
	unoconv --doctype=graphics --format=wmf $<
 
%.emf: %.$(EXT)
	unoconv --doctype=graphics --format=emf $<
 
### Phony targets
all: listener raster vector
 
new: clean all
 
listener:
	unoconv --listener &
	sleep 1
 
clean:
	@echo "$(MAKE): Clean up workspace..."
	@rm -fv $(PDF)
	@rm -fv $(SVG)
	@rm -fv $(EPS)
	@rm -fv $(PNG)
	@rm -fv $(GIF)
	@rm -fv $(WMF)
	@rm -fv $(JPG)
	@rm -fv $(EMF)
	@rm -fv $(BMP)
	@echo "$(MAKE): Done."
Anmelden
About this site