diff --git a/README.md b/README.md index d5c7a19..3a9e8a5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ I use this script to place the arch logo on all my wallpapers. ## Example 2 ![example2](examples/example2.jpg) -![arch btw example2](examples/arch_btw_examplew.jpg) +![arch btw example2](examples/arch_btw_example2.jpg) ## Example 3 ![example3](examples/example3.jpg) diff --git a/arch.png b/arch.png deleted file mode 100644 index af62f7b..0000000 Binary files a/arch.png and /dev/null differ diff --git a/arch.svg b/arch.svg new file mode 100644 index 0000000..dd52360 --- /dev/null +++ b/arch.svg @@ -0,0 +1 @@ + diff --git a/examples/arch_btw_example1.jpg b/examples/arch_btw_example1.jpg index c76c960..0e00afe 100644 Binary files a/examples/arch_btw_example1.jpg and b/examples/arch_btw_example1.jpg differ diff --git a/examples/arch_btw_example2.jpg b/examples/arch_btw_example2.jpg new file mode 100644 index 0000000..142aa3f Binary files /dev/null and b/examples/arch_btw_example2.jpg differ diff --git a/examples/arch_btw_example3.jpg b/examples/arch_btw_example3.jpg index 12e1901..18595d1 100644 Binary files a/examples/arch_btw_example3.jpg and b/examples/arch_btw_example3.jpg differ diff --git a/examples/arch_btw_examplew.jpg b/examples/arch_btw_examplew.jpg deleted file mode 100644 index fed5be6..0000000 Binary files a/examples/arch_btw_examplew.jpg and /dev/null differ diff --git a/mepapemaker.sh b/mepapemaker.sh index fe1395f..031d6a7 100755 --- a/mepapemaker.sh +++ b/mepapemaker.sh @@ -2,27 +2,44 @@ pape=$1 -# Get the width of the wallpaper -height=$(magick convert "$pape" -format "%h" info:) -width=$(magick convert "$pape" -format "%w" info:) +# get the width of the wallpaper +height=$(magick identify -format "%h" "$pape") +width=$(magick identify -format "%w" "$pape") -# Calculate appropriate height for logo on the wallpaper -logo_height=$(($height*9/16)) +# determine smaller dimension to use for scale +if [[ "$height" -lt "$width" ]]; then + scale_val=$height +else + scale_val=$width +fi -# Generate Mask -convert "./arch.png" -gravity center -resize $logo_height -background white -extent "${width}x${height}" -flatten "temp_logo.png" +# 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}") -# Generate Wallpaper +# generate a PNG mask from the source svg +convert \ + -density $density \ + -gravity center \ + -background white \ + -extent "${width}x${height}" \ + arch.svg \ + tmp_arch_mask.png + +# generate wallpaper name outfile_name=$(basename "$pape") -convert "$pape" -write-mask "temp_logo.png" -gravity center \ - -blur 0x30 \ - -attenuate 0.3 +noise Laplacian\ - -evaluate Multiply 1.3 \ - "arch_btw_$outfile_name" +# add arch mask to original image +convert \ + -write-mask "tmp_arch_mask.png" \ + -gravity center \ + -blur 0x30 \ + -attenuate 0.3 \ + +noise Laplacian \ + -evaluate Multiply 1.3 \ + "$pape" \ + "arch_btw_$outfile_name" -# Delete temporary file -rm "temp_logo.png" - -# TODO: imagemagick giving colorspace warning -# TODO: Use SVG instead of png? +# delete temporary file +rm "tmp_arch_mask.png"