the-honk/.husky/scripts/pdfToPng.sh

23 lines
460 B
Bash
Raw Normal View History

2024-10-09 17:02:46 +00:00
#!/bin/bash
find . -print0 | while IFS= read -r -d '' file
do
if [ -f "$file" ]; then
if [[ $file == *pdf ]]; then
mkdir temp
gm convert "$file" +adjoin temp/temp%02d.png
for temp in ./temp/*.png
do
gm convert "$temp" -fuzz 80% -trim +repage -bordercolor white -border 50x25 "$temp"
done
readarray -d . -t arr <<< $file
gm convert -append ./temp/*.png "${arr[1]:1}.png"
rm -rf temp
rm "$file" "${arr[1]:1}.synctex.gz"
fi
fi
done