Last active
March 29, 2024 15:58
-
-
Save owulveryck/1317f9b22433aa18778b673000159141 to your computer and use it in GitHub Desktop.
Revisions
-
owulveryck revised this gist
Oct 13, 2023 . 2 changed files with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ IMAGE_LIST_FILE = slides.txt TEMP_DIR = temp_msg # Custom message to be added at the bottom of each image MESSAGE = Olivier Wulveryck - OCTO Technology # Blank image BLANK = blank.png @@ -41,12 +41,14 @@ $(BACKGROUND_IMAGE): $(OUTPUT): $(IMAGE_LIST_FILE) $(BACKGROUND_IMAGE) svg2png mkdir -p $(TEMP_DIR) counter=1; \ while IFS='|' read -r img title; do \ temp_img="$(TEMP_DIR)/temp_$$(printf "%03d" $$counter)_$$(basename $$img)"; \ output_file="$(TEMP_DIR)/$$(printf "%03d" $$counter)_$$(basename $$img)"; \ convert "$$img" -contrast -resize 1752x1284 -background none -gravity center -extent 1752x1284 -colorspace Gray -colors 8 "$$temp_img"; \ convert -background none -fill white -gravity Center -pointsize 20 label:"$$title" label.png; \ convert $(BACKGROUND_IMAGE) label.png -gravity North -geometry +0+20 -composite slide.png; \ composite -gravity center "$$temp_img" slide.png "$$output_file"; \ rm "$$temp_img" label.png slide.png; \ counter=$$((counter + 1)); \ done < $(IMAGE_LIST_FILE) convert -units PixelsPerInch -density 150x150 $(TEMP_DIR)/* $@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ front.png|This title is displayed on top blank.png|This a blank slide with this title -
owulveryck revised this gist
Oct 6, 2023 . No changes.There are no files selected for viewing
-
owulveryck revised this gist
Oct 6, 2023 . 1 changed file with 21 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Makefile to convert images (JPG or PNG) to a grayscale 4-bit PDF with a custom message, contrast adjustment, 8 levels of gray, and a background image using ImageMagick # Output PDF file name OUTPUT = output.pdf @@ -10,41 +10,54 @@ IMAGE_LIST_FILE = slides.txt TEMP_DIR = temp_msg # Custom message to be added at the bottom of each image MESSAGE = Olivier Wulveryck - 2023 # Blank image BLANK = blank.png # Background image BACKGROUND = background.png # SVG files to be converted to PNG SVG_FILES = $(wildcard *.svg) PNG_FILES = $(SVG_FILES:.svg=.png) # # Background image with rounded corners and annotation BACKGROUND_IMAGE = background.png # Conversion rule all: $(BLANK) $(OUTPUT) $(BACKGROUND_IMAGE) $(BLANK): convert -size 1872x1404 xc:white $(BLANK) $(BACKGROUND_IMAGE): convert -size 1872x1404 xc:white -fill none -stroke gray -strokewidth 60 -draw "roundrectangle 30,30 1842,1374 45,45" rounded.png convert -background none -fill white -gravity Center -pointsize 20 label:'$(MESSAGE)' label.png convert rounded.png label.png -gravity South -geometry +0+20 -composite $(BACKGROUND_IMAGE) rm rounded.png label.png $(OUTPUT): $(IMAGE_LIST_FILE) $(BACKGROUND_IMAGE) svg2png mkdir -p $(TEMP_DIR) counter=1; \ while IFS= read -r img; do \ temp_img="$(TEMP_DIR)/temp_$$(printf "%03d" $$counter)_$$(basename $$img)"; \ output_file="$(TEMP_DIR)/$$(printf "%03d" $$counter)_$$(basename $$img)"; \ convert "$$img" -contrast -resize 1752x1284 -background none -gravity center -extent 1752x1284 -colorspace Gray -colors 8 "$$temp_img"; \ composite -gravity center "$$temp_img" $(BACKGROUND_IMAGE) "$$output_file"; \ rm "$$temp_img"; \ counter=$$((counter + 1)); \ done < $(IMAGE_LIST_FILE) convert -units PixelsPerInch -density 150x150 $(TEMP_DIR)/* $@ rm -rf $(TEMP_DIR) svg2png: $(PNG_FILES) %.png: %.svg convert $< $@ clean: rm -f $(OUTPUT) $(BLANK) $(PNG_FILES) .PHONY: all clean svg2png -
owulveryck revised this gist
Oct 6, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ IMAGE_LIST_FILE = slides.txt TEMP_DIR = temp_msg # Custom message to be added at the bottom of each image MESSAGE = Olivier Wulveryck # Blank image BLANK = blank.png -
owulveryck created this gist
Oct 6, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ # Makefile to convert images (JPG or PNG) to a grayscale 4-bit PDF with a custom message using ImageMagick # Output PDF file name OUTPUT = output.pdf # File containing the list of image filenames IMAGE_LIST_FILE = slides.txt # Temporary directory for images with messages TEMP_DIR = temp_msg # Custom message to be added at the bottom of each image MESSAGE = Olivier Wulveryck - OCTO Technology # Blank image BLANK = blank.png # SVG files to be converted to PNG SVG_FILES = $(wildcard *.svg) PNG_FILES = $(SVG_FILES:.svg=.png) # Conversion rule all: $(BLANK) $(OUTPUT) $(BLANK): convert -size 1872x1404 xc:white $(BLANK) $(OUTPUT): $(IMAGE_LIST_FILE) mkdir -p $(TEMP_DIR) counter=1; \ while IFS= read -r img; do \ output_file="$(TEMP_DIR)/$$(printf "%03d" $$counter)_$$(basename $$img)"; \ convert "$$img" -contrast -resize 1872x1404 -background white -gravity center -extent 1872x1404 -colorspace Gray -colors 8 -gravity SouthWest -pointsize 24 -annotate +10+10 '$(MESSAGE)' "$$output_file"; \ counter=$$((counter + 1)); \ done < $(IMAGE_LIST_FILE) convert -units PixelsPerInch -density 150x150 $(TEMP_DIR)/* $@ rm -rf $(TEMP_DIR) svg2png: $(PNG_FILES) %.png: %.svg convert $< $@ clean: rm -f $(OUTPUT) $(BLANK) .PHONY: all clean