From 0d05ef1e12314985988e567ac22a179d0f646899 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 10:33:04 -0600 Subject: Inital Commit --- .local/bin/hide | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 .local/bin/hide (limited to '.local/bin/hide') diff --git a/.local/bin/hide b/.local/bin/hide new file mode 100755 index 0000000..1dc473d --- /dev/null +++ b/.local/bin/hide @@ -0,0 +1,64 @@ +#!/bin/bash + +#Description: +#This hides an image within an image as an overlay. Useful for watermarking images. + +#1 is foreground +#2 is background +#3 is output +#gemsize is an env var for dictating how big or small the overlayed photo should be +#TMPDIR is an env var for dictating where temporary files for this program should be stored + +#Axioms: + +#Dependencies: https://packages.debian.org/sid/imagemagick + + +if [ "$TMPDIR" = "" ] +then + TMPDIR=/tmp +fi + + +rotation=$(echo "$RANDOM%360"|bc) +#widthforeground=$(identify -format "%[fx:w]" "/home/$USER/Pictures/wojak/soy/5486*") +#heightforeground=$(identify -format "%[fx:h]" "/home/$USER/Pictures/wojak/soy/5486*") +widthbackground=$(identify -format "%[fx:w]" "$1") +heightbackground=$(identify -format "%[fx:h]" "$1") + + +if [ "$gemsize" = "" ] +then + foregroundresizefactor=$(echo "$heightbackground*0.15"|bc)x +else + foregroundresizefactor=$(echo "$heightbackground*$gemsize"|bc)x +fi + +foregroundLegalMovingDistanceWidth=$(echo "$widthbackground/2"|bc) +foregroundLegalMovingDistanceHeight=$(echo "$heightbackground/2"|bc) + +foregroundActualMovingDistanceWidth=$(echo "$RANDOM%$foregroundLegalMovingDistanceWidth"|bc) +foregroundActualMovingDistanceHeight=$(echo "$RANDOM%$foregroundLegalMovingDistanceHeight"|bc) + +if [[ $(echo "$RANDOM%2"|bc) == 0 ]] +then + foregroundActualMovingDistanceWidth=-$foregroundActualMovingDistanceWidth +fi + +if [[ $(echo "$RANDOM%2"|bc) == 0 ]] +then + foregroundActualMovingDistanceHeight=-$foregroundActualMovingDistanceHeight +fi + +convert "$2" -alpha set -background none -colorspace RGB -trim -rotate "$rotation" -fuzz 10% -transparent White -resize "$foregroundresizefactor" -trim "$TMPDIR/trans.png" +composite -dissolve 70% -gravity center -geometry +"$foregroundActualMovingDistanceWidth"+"$foregroundActualMovingDistanceHeight" "$TMPDIR/trans.png" "$1" "$3" +rm "$TMPDIR/trans.png" + +echo "$(identify -ping -format '%[width]' "$3")*0.5"|bc +echo "$(identify -ping -format '%[height]' "$3")*0.5"|bc + +finalwidth=$(echo "$(identify -ping -format '%[width]' "$3")*0.5"|bc) +finalheight=$(echo "$(identify -ping -format '%[height]' "$3")*0.5"|bc) +xlocation=$(echo "$finalwidth-$foregroundActualMovingDistanceWidth"|bc) +ylocation=$(echo "$finalheight-$foregroundActualMovingDistanceWidth"|bc) +echo "hidden gem is at ($xlocation, $ylocation)" -- cgit v1.2.3