diff --git a/make-includes/standard_rules.make b/make-includes/standard_rules.make index 586c2b2..55dc3f4 100755 --- a/make-includes/standard_rules.make +++ b/make-includes/standard_rules.make @@ -88,12 +88,31 @@ $(call xslt,$<,xml2html.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)')) > $@ endif # -# PNG from TIFF (normal) +# Image rules can be a bit messy, because the prerequisite might be in any one +# of several different formats, but we want to apply the same commands anyway +# (e.g., ImageMagick convert) to generate the target. It would be nice if we +# could specify variable file types in a prerequisite of a pattern rule (e.g., +# %-foo.png: %.png %.jpg %.tif), but unfortunately we can't :(. The solution is +# to create a make function to refactor the commands, and then specify as many +# rules as required depending on the number of file formats. We still end up +# repeating the rule actions, but at least the guts of the action is coded only +# once in the function. # +# PNG from TIFF, JPEG, PICT (normal image) +# Note: The second rule omits the %.png target to avoid a circular dependency. +# +convert_normal = `$(CONVERT) "$(1)" "$(2)"` + %.png %-print.png %-web.png: %.tif - $(CONVERT) "$<" $(IMGDIR)/$@ + $(call convert-normal,$<,$(IMGDIR)/$@) + +%.png %-print.png %-web.png: %.jpg + $(call convert-normal,$<,$(IMGDIR)/$@) + +%.png %-print.png %-web.png: %.pict + $(call convert-normal,$<,$(IMGDIR)/$@) # -# PNG from TIFF (slide background) +# PNG from PNG, TIFF, JPEG, PICT (slide background) # # We lighten these so that they don't overwhelm the text. Note that 15% is # too light for most data projectors, so let's try 33% and see what @@ -102,18 +121,35 @@ # # Includes both blurred and unblurred versions, use as required. # -%-BG.png: $(IMGDIR)/%.tif - $(CONVERT) $< -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% $< - $(IMGDIR)/$@ +# Unblurred: +convert_bg = `$(CONVERT) "$(1)" -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% "$(1)" - "$(2)"` + +%-BG.png: %.tif + $(call convert_bg,$<,$(IMGDIR)/$@) + +%-BG.png: %.png + $(call convert_bg,$<,$(IMGDIR)/$@) + +%-BG.png: %.jpg + $(call convert_bg,$<,$(IMGDIR)/$@) + +%-BG.png: %.pict + $(call convert_bg,$<,$(IMGDIR)/$@) # +# Blurred: +convert_bg_blur = `$(CONVERT) -blur 0.5 "$(1)" "$(2)"; $(CONVERT) "$(2)" -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% "$(2)" - "$(3)"; rm -f "$(2)"` + %-BG-blur.png: %.tif - $(CONVERT) -blur 0.5 $< $(IMGDIR)/$*.png - $(CONVERT) $(IMGDIR)/$*.png -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% $(IMGDIR)/$*.png - $(IMGDIR)/$@ - @rm -f $(IMGDIR)/$*.png -# -# PNG from PICT. -# -%.png %-print.png %-web.png: %.pict - $(CONVERT) "$<" $(IMGDIR)/$@ + $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) + +%-BG-blur.png: %.png + $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) + +%-BG-blur.png: %.jpg + $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) + +%-BG-blur.png: %.pict + $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) # # PNG from XCF. # @@ -194,6 +230,12 @@ %-web-zoom.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=144 --export-png=$(IMGDIR)/$@ +%-print-zoom.png: %.svg + $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=300 --export-png=$(IMGDIR)/$@ + +%-print-zoom-transparent.png: %.svg + $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=0 --export-dpi=300 --export-png=$(IMGDIR)/$@ + %-transparent.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=0 --export-dpi=96 --export-png=$(IMGDIR)/$@ #