#---*- Makefile -*-------------------------------------------------------
#$Author: saulius $
#$Date: 2019-10-16 10:31:34 +0300 (Wed, 16 Oct 2019) $
#$Revision: 226 $
#$URL: svn+ssh://saulius-grazulis.lt/home/saulius/svn-repositories/makefiles/xetex-and-latex/Makelocal-xetex-and-latex $
#------------------------------------------------------------------------
#*
# Convert images to formats suitable for (Xe)LaTeX
#**

figures/%.eps.gz: molscript/outputs/%.tif
	tifftopnm $< | pnmtops -noturn | gzip -vc > $@
	zcat $@ | grep '%%BoundingBox' > $(dir $@)$*.eps.bb

# As suggested in
# https://www.reddit.com/r/GIMP/comments/99mtfg/how_to_batch_convert_xcf_files_to_jpg_or_png/,
# https://opensource.com/article/21/1/gimp-scripting:
%.png: %.xcf
	scripts/gimp-xcf2png  $< $@

figures/%.eps: drawings/%.fig
	fig2dev -L eps $< $@

figures/%.pstex_t: drawings/%.fig
	fig2dev -L pstex_t $< $@
	fig2dev -L pstex $<

figures/%.eps.gz: drawings/%.png
	pngtopnm $< | pnmtops -noturn | gzip -vc > $@
	zcat $@ | grep '%%BoundingBox' > $(dir $@)$*.eps.bb

%.eps.gz: %.png
	pngtopnm $< | pnmtops -noturn | gzip -vc > $@
	zcat $@ | grep '%%BoundingBox' > $*.eps.bb

%.eps.gz: %.jpg
	jpegtopnm $< | pnmtops -noturn | gzip -vc > $@
	zcat $@ | grep '%%BoundingBox' > $*.eps.bb

R-figures/outputs/%.eps: R-figures/%.com
	${MAKE} -C $(dir $<)
