Skip to content

Instantly share code, notes, and snippets.

@astatide
Last active October 27, 2023 21:07
Show Gist options
  • Select an option

  • Save astatide/210a1cc087af205033ce204e2ea17e34 to your computer and use it in GitHub Desktop.

Select an option

Save astatide/210a1cc087af205033ce204e2ea17e34 to your computer and use it in GitHub Desktop.
Wrath of the Righteous auto portrait downloader/cropper
{
"portraits": [
{
"URL": "https://i.pinimg.com/originals/d1/60/3c/d1603cc29275cec1fca741b48fa46921.png",
"resize": ["1.5", "1", "1"],
"tweaks": ["+0+40", "+0+0", "+0+0"]
},
{
"URL": "https://i.pinimg.com/originals/46/4a/6d/464a6d9fb5de785359f72a55b82bc863.jpg",
"resize": ["3.5", "2", "1.5"],
"tweaks": ["+0+25", "+0+0", "+0+0"]
},
{
"URL": "https://i.pinimg.com/originals/51/34/78/5134782571c896c3d4bc5947f8d37a5a.jpg",
"resize": ["1", "1", "1"],
"tweaks": ["+10+0", "+0+0", "+0+0"]
}
]
}
#! /usr/bin/env bash
STEAM_DIR=$HOME/.steam/steam
PORTRAITS=$STEAM_DIR/steamapps/compatdata/1184370/pfx/drive_c/users/steamuser/AppData/LocalLow/Owlcat\ Games/Pathfinder\ Wrath\ Of\ The\ Righteous/Portraits/
SMALL="185x242+0+0"
MEDIUM="330x432+0+0"
FULLENGTH="692x1024+0+0"
sizeArray=("185x242" "330x432" "692x1024")
fileArray=("Small.png" "Medium.png" "Fulllength.png")
# these should really be per file but whatever for now
#resizeArray=("3.5" "2" "1.5") # element 2
END=`cat ~/pathfinder.json | jq '.portraits | length'`;
## customize this for yourself!
for i in $(eval echo "{0..$(($END-1))}"); do
folder=$(printf "%04d" $(($i+1)))
mkdir -p "$PORTRAITS"/"$folder"
cd "$PORTRAITS"/"$folder"
URL=`cat ~/pathfinder.json | jq -r ".portraits | .[$i] | .URL"`
echo $URL
wget $URL
r1=`cat ~/pathfinder.json | jq -r ".portraits | .[$i] | .resize | .[0]"`
r2=`cat ~/pathfinder.json | jq -r ".portraits | .[$i] | .resize | .[1]"`
r3=`cat ~/pathfinder.json | jq -r ".portraits | .[$i] | .resize | .[2]"`
resizedArray=("$(echo "185*$r1" | bc)x$(echo "242*$r1" | bc)" "$(echo "330*$r2" | bc)x$(echo "432*$r2" | bc)" "$(echo "692*$r3" | bc)x$(echo "1024*$r3"| bc)")
for j in ${!sizeArray[@]}; do
# -gravity center # both vertical and horizontal
# -gravity north?
tweak=`cat ~/pathfinder.json | jq -r ".portraits | .[$i] | .tweaks | .[$j]"`
magick convert $URL -gravity north -geometry "${resizedArray[$j]}^" -crop "${sizeArray[$j]}$tweak" ${fileArray[$j]}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment