moved logo svg to its own folder, modified script to enable use of other logos and added error and usage messages
This commit is contained in:
parent
a3e681c85e
commit
50b6585cd8
2 changed files with 42 additions and 15 deletions
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
@ -1,46 +1,73 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
pape=$1
|
||||
logo=$1
|
||||
pape=$2
|
||||
|
||||
# get the width of the wallpaper
|
||||
height=$(magick identify -format "%h" "$pape")
|
||||
width=$(magick identify -format "%w" "$pape")
|
||||
if [[ -z "$logo" ]] || [[ -z "$pape" ]]; then
|
||||
echo $'Usage: ./mepapemaker.sh <logo> <wallpaper>\n\n<logo> is the logo name without the svg file extension.\nFor <wallpaper>, all image formats supported by\nImageMagick are valid targets.'
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f "./logo/$logo.svg" ]; then
|
||||
echo $'No such logo found.\nCheck the logo directory for available options or add\nyour own <logo>.svg to the directory.'
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f "$pape" ]; then
|
||||
echo $'Wallpaper not found. Maybe you mistyped?'
|
||||
exit
|
||||
fi
|
||||
|
||||
# get the width and height of the logo
|
||||
lheight=$(magick identify -format "%h" "./logo/$logo.svg")
|
||||
lwidth=$(magick identify -format "%w" "./logo/$logo.svg")
|
||||
|
||||
# determine smaller dimension to use for scale
|
||||
if [[ "$height" -lt "$width" ]]; then
|
||||
scale_val=$height
|
||||
if [[ "$lheight" -lt "$lwidth" ]]; then
|
||||
lscale_val=$lheight
|
||||
else
|
||||
scale_val=$width
|
||||
lscale_val=$lwidth
|
||||
fi
|
||||
|
||||
# get the width and height of the wallpaper
|
||||
pheight=$(magick identify -format "%h" "$pape")
|
||||
pwidth=$(magick identify -format "%w" "$pape")
|
||||
|
||||
# determine smaller dimension to use for scale
|
||||
if [[ "$pheight" -lt "$pwidth" ]]; then
|
||||
pscale_val=$pheight
|
||||
else
|
||||
pscale_val=$pwidth
|
||||
fi
|
||||
|
||||
# calculate appropriate density to scale the svg
|
||||
# 25 is the dimension of either side of the svg
|
||||
# 50 is the rough scale of the logo that will be on the final image (in %)
|
||||
density=$(awk "BEGIN {print ($scale_val/25.0)*50}")
|
||||
density=$(awk "BEGIN {print ($pscale_val/($lscale_val+2).0)*50}")
|
||||
|
||||
# generate a PNG mask from the source svg
|
||||
magick \
|
||||
-density $density \
|
||||
-gravity center \
|
||||
arch.svg \
|
||||
./logo/$logo.svg \
|
||||
-background white \
|
||||
-extent "${width}x${height}" \
|
||||
-extent "${pwidth}x${pheight}" \
|
||||
-resize 100% \
|
||||
tmp_arch_mask.png
|
||||
tmp_mask.png
|
||||
|
||||
# generate wallpaper name
|
||||
outfile_name=$(basename "$pape")
|
||||
outfile_name=${logo}_btw_$(basename "$pape")
|
||||
|
||||
# add arch mask to original image
|
||||
magick \
|
||||
"$pape" \
|
||||
-write-mask "tmp_arch_mask.png" \
|
||||
-write-mask "tmp_mask.png" \
|
||||
-gravity center \
|
||||
-blur 0x30 \
|
||||
-attenuate 0.3 \
|
||||
+noise Laplacian \
|
||||
-evaluate Multiply 1.3 \
|
||||
"arch_btw_$outfile_name"
|
||||
"$outfile_name"
|
||||
|
||||
# delete temporary file
|
||||
rm "tmp_arch_mask.png"
|
||||
rm "tmp_mask.png"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue