Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
150e339
add scraping script, and preliminary css
simeydotme Dec 11, 2022
5381882
add new data and masked image condition for styles
simeydotme Dec 12, 2022
77e2060
add new card data
simeydotme Dec 13, 2022
f9cdbe2
improve data and effects from masks
simeydotme Dec 15, 2022
1c6db17
improve foil effects for rainbow/rainbow-alt
simeydotme Dec 18, 2022
c89528b
massive improvements for rainbow/vmax-alts
simeydotme Dec 19, 2022
2d905e7
finish off the styling for rare-holo and trainer galleries
simeydotme Dec 20, 2022
62c00a6
improve holo foils again
simeydotme Dec 20, 2022
93fcd6e
start component refactoring
simeydotme Dec 21, 2022
cddcbb1
add pikachu trainer gallery, improve styles
simeydotme Dec 22, 2022
4dadcaa
final improvement for regular holo cards
simeydotme Dec 22, 2022
43f3e3c
add radiant holo standalone, improve variables and clips
simeydotme Dec 23, 2022
f68ed36
add trainer holo to standalone css file
simeydotme Dec 23, 2022
74feae2
add regular v-holo cards to separate file
simeydotme Dec 23, 2022
353d1e6
add v-full-art css standalone
simeydotme Dec 23, 2022
eab0433
add vmax, vstar, rainbow and alternate cards standalone css
simeydotme Dec 25, 2022
04101fb
improve vmax/vstar and unify colours
simeydotme Dec 26, 2022
f913f7e
improve vstar edge masking
simeydotme Dec 26, 2022
a7d46a7
add secret rare standalone css
simeydotme Dec 26, 2022
715e81f
TG v & vmax into separate file, fix TG Holo
simeydotme Dec 26, 2022
84a716a
improve secret rare
simeydotme Dec 26, 2022
fe998c0
fix clipping, improve holos, change trainer ful art data
simeydotme Dec 27, 2022
3d8fae1
remove test files
simeydotme Dec 27, 2022
259a8ef
big improvements / refactor of the card js/css
simeydotme Dec 28, 2022
4fe4a2f
add Amazing Rare, refactor "mask" names in app.svelte
simeydotme Dec 30, 2022
63b2c00
add new shiny rare, fix clip paths, improve some styles
simeydotme Jan 1, 2023
b24017c
improve shiny rares
simeydotme Jan 1, 2023
dbf12f7
change shiny cards, improve clippings
simeydotme Jan 1, 2023
ae44251
add a proxy card to populate certain fields, also non-masked css
simeydotme Jan 2, 2023
06a4ea8
add x-browser css
simeydotme Jan 3, 2023
74ddeb9
standardise the data, add "alternate arts" lookup
simeydotme Jan 3, 2023
e466df0
add proxy and app data to make cards work without foil/rarity
simeydotme Jan 3, 2023
d41933d
modif css to work with new 2x foils better
simeydotme Jan 5, 2023
3e97a4a
update proxy card to use cdn foils
simeydotme Jan 5, 2023
13671ea
cleanup image scraper script for new foil/mask adjustments
simeydotme Jan 8, 2023
e1cfed7
remove extra mask layers for new mask alpha
simeydotme Jan 8, 2023
a83d666
add new css to match new masking alpha, improve gold cards a lot
simeydotme Jan 8, 2023
4b4dba9
improve styles for gold cards
simeydotme Jan 9, 2023
fa5d964
update proxy svelte to use remote files again
simeydotme Jan 9, 2023
4b8af6d
fix glare on black secret
simeydotme Jan 9, 2023
7338322
clean up some math, update descriptions, improve mobile layout
simeydotme Jan 15, 2023
77d323e
some performance improvements
simeydotme Jan 15, 2023
750a353
fix z-index
simeydotme Jan 15, 2023
2c24cfd
improve styling for full-art cards, fix image rendering
simeydotme Jan 24, 2023
a104b56
add better non-masked styles
simeydotme Jan 24, 2023
caab991
split shiny css, improve no-mask shiny css
simeydotme Jan 25, 2023
4df26a3
improve vmax shine effect, fix all -webkit-
simeydotme Jan 25, 2023
d4cef39
change grain to be webp for performance
simeydotme Jan 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup image scraper script for new foil/mask adjustments
- make mask more contrasty/alphay
  • Loading branch information
simeydotme committed Jan 8, 2023
commit 13671eab0274e5b26b31d415d20459df2020c9d9
293 changes: 204 additions & 89 deletions public/img_scrape.sh
Original file line number Diff line number Diff line change
@@ -1,128 +1,243 @@


outputDirectory=$1
jsonFile=$2
FOLDER=$1
REMOTE_JSON=$2

_extract() {
echo ${1} | base64 --decode | jq -r ${2};
}
# fetch JSON file
echo "📃 Fetching JSON ~ ${jsonFile}..."

# JSON=$( curl $jsonFile ); # 🌐 remote JSON file
# JSON=$( cat $jsonFile ); # 💻 local JSON file
FOLDER="${outputDirectory}"; # local folder
create_directories() {

echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ↯ 📂 Create directories for images... "
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

# make folders for images to go in, if needed
mkdir -p "$FOLDER/foils/upscaled";
mkdir -p "$FOLDER/masks/upscaled";
echo "📂 Create directories for images...";
mkdir -p "$FOLDER/foils/upscaled";
mkdir -p "$FOLDER/masks/upscaled";

CURL_BATCH="";
LOOP_COUNT=0;
}

fetch_json() {

if [[ -n $REMOTE_JSON ]]; then

echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ↯ 📃 Fetching JSON ┃ $REMOTE_JSON "
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

JSON=$( curl $REMOTE_JSON ); # 🌐 remote JSON file
# JSON=$( cat $REMOTE_JSON ); # 💻 local JSON file

else

echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ↯ ⛔ No JSON Provided, not fetching"
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

fi

}

download_images() {

if [[ -n $JSON ]]; then

local CURL_BATCH="";
local LOOP_COUNT=0;

for row in $( jq -r '.[] | @base64'); do

local FOIL_TYPE=$( _extract ${row} '._foil_mask' );
local FOIL_EFFECT=$( _extract ${row} '._foil_effect' );

# for row in $( jq -r '.[] | @base64'); do
# only continue if there's a foil image (some are null)
if [[ $FOIL_TYPE != 'None' ]]; then

# FOIL_TYPE=$( _extract ${row} '._foil_mask' );
# FOIL_EFFECT=$( _extract ${row} '._foil_effect' );
# get the foil image value
local FOIL_IMG=$( _extract ${row} '._foil_img' );

# # only continue if there's a foil image (some are null)
# if [[ $FOIL_TYPE != 'None' ]]; then
# get name/path parts
local EXT="${FOIL_IMG##*.}";
local SERIES=$( _extract ${row} '._ptcgo_set' );
local NUMBER=$( _extract ${row} '.collector_number.numerator' );
local NUMBER="${NUMBER/'SWSH'/}"
local SUFFIX="_${FOIL_TYPE,,}_${FOIL_EFFECT,,}";
local SUFFIX="${SUFFIX/'reverse_flatsilver'/'holo_reverse'}"

# # get the foil image value
# FOIL_IMG=$( _extract ${row} '._foil_img' );
# create new name/output
local NAME="${NUMBER,,}_foil$SUFFIX.$EXT";
local OUTPUT="${FOLDER}/masks/${NAME}";

# # get name/path parts
# EXT="${FOIL_IMG##*.}";
# SERIES=$( _extract ${row} '._ptcgo_set' );
# NUMBER=$( _extract ${row} '.collector_number.numerator' );
# NUMBER="${NUMBER/'SWSH'/}"
# SUFFIX="_${FOIL_TYPE,,}_${FOIL_EFFECT,,}";
# SUFFIX="${SUFFIX/'reverse_flatsilver'/'holo_reverse'}"
echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ↯ 🔻 Downloading ${FOIL_IMG##*/} -> ${NAME}..."
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

# download the source image
CURL_BATCH="${CURL_BATCH}\\nurl=\"${FOIL_IMG}\"\\noutput=\"${OUTPUT}\"\\n";

# # create new name/output
# NAME="${NUMBER,,}_foil$SUFFIX.$EXT";
# OUTPUT="${FOLDER}/masks/${NAME}";
fi

# # download the source image
# echo "🔻 Downloading ${FOIL_IMG##*/} -> ${NAME}..."
# # curl -sN $FOIL_IMG -o $OUTPUT # curl 1-by-1, not good.
# CURL_BATCH="${CURL_BATCH}\\nurl=\"${FOIL_IMG}\"\\noutput=\"${OUTPUT}\"\\n";
done < <( echo $JSON )

# fi
echo "";
echo -e "$CURL_BATCH" | curl --parallel --parallel-immediate --parallel-max 20 --config -;
echo "";

# done < <( echo $JSON )
echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ↯ ✅ Finished Downloading from ${$JSON} "
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

echo "";
# echo -e "$CURL_BATCH" | curl --parallel --parallel-immediate --parallel-max 20 --config -;
echo "";
else

echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ↯ ⛔ No JSON Provided, not downloading images"
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

fi


}

echo "✅ Finish downloading"
echo "";

# ======================================================================


for file in ${FOLDER}/masks/*.png; do
upscale() {

# get filename for the image
FILENAME=$( echo "${file##*/}" | cut -f 1 -d '.' );
echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ⇑ 🔼 Upscaling / Converting ${FOLDER} "
echo "├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";
echo "│ ";

echo "";
echo "🔁 Upscaling & Converting ${file##*/}..."
echo "";
for file in ${FOLDER}/masks/*.png; do

# output for 2x masks
UPSCALE_MASK2="${FOLDER}/masks/upscaled/${FILENAME}_2x.png";
# output for 4x masks
UPSCALE_MASK4="${FOLDER}/masks/upscaled/${FILENAME}_4x.png";
# get filename for the image
local FILENAME=$( echo "${file##*/}" | cut -f 1 -d '.' );
local SUFFIX="up"

echo " 🔼 Upscaling Image with realesrgan.py @ 4️⃣";
python3 ~/Real-ESRGAN/inference_realesrgan.py -i ${file} --suffix 4x -o ${FOLDER}/masks/upscaled/
# echo "┝ 🔼 Upscaling & Converting ${file##*/}..."

echo " 🔼 ◼ Creating Mask image @ 4️⃣";
convert ${UPSCALE_MASK4} -modulate 100x0 -brightness-contrast 50x60 "${UPSCALE_MASK4}";
# params for conversions
local mask_alpha="-alpha set -background none -channel A -evaluate multiply 8 +channel"
local mask_brightness=""
local desaturate="-modulate 100x0"
local downsize="-colorspace LAB -filter Lanczos2 -distort resize 50% -colorspace sRGB"
local remove_alpha="-background black -alpha remove -alpha off"
local foil_brightness="-channel RGB -brightness-contrast 63x73"

echo " 🔼 ◼ Creating Mask image @ 2️⃣";
convert ${UPSCALE_MASK4} -modulate 100x0 -colorspace LAB -filter Lanczos2 -distort resize 50% -colorspace sRGB "${UPSCALE_MASK2}";
if [[ $FILENAME =~ .*etched.* ]]; then
# only need to boost brightness on etched cards
mask_brightness="-channel RGB -brightness-contrast 32x52"
fi

# output for 4x masks
local UPSCALED="${FOLDER}/masks/upscaled/${FILENAME}_${SUFFIX}.png";
# output for 2x masks
local UPSCALE_MASK2="${FOLDER}/masks/upscaled/${FILENAME}_2x.png";
# output for 4x masks
local UPSCALE_MASK4="${FOLDER}/masks/upscaled/${FILENAME}_4x.png";

# echo "│ 🟣 🔼 4️⃣ Upscaling Mask Image with realesrgan.py";
python3 ~/Real-ESRGAN/inference_realesrgan.py -i ${file} --suffix ${SUFFIX} -o ${FOLDER}/masks/upscaled/

# echo "│ 🔵 🔼 4️⃣ Simplifying Mask image";
convert ${UPSCALED} ${mask_alpha} ${mask_brightness} "${UPSCALE_MASK4}";

# echo "│ 🔵 🔽 2️⃣ Downsampling Mask image";
convert ${UPSCALE_MASK4} ${desaturate} ${downsize} "${UPSCALE_MASK2}";

# ======================================================================

# output for 1x foils
local OUTPUT_FOIL1="${FOLDER}/foils/${FILENAME}.png";
# output for 2x foils
local OUTPUT_FOIL2="${FOLDER}/foils/upscaled/${FILENAME}_2x.png";
# output for 4x foils
local OUTPUT_FOIL4="${FOLDER}/foils/upscaled/${FILENAME}_4x.png";

# echo "│ ⚫ 1️⃣ Creating Greyscale image";
convert ${file} ${desaturate} ${remove_alpha} ${foil_brightness} "${OUTPUT_FOIL1}";

# echo "│ ⚫ 2️⃣ Creating Greyscale image";
convert ${UPSCALED} ${desaturate} ${remove_alpha} ${foil_brightness} ${downsize} "${OUTPUT_FOIL2}";

# echo "│ ⚫ 4️⃣ Creating Greyscale image";
convert ${UPSCALED} ${desaturate} ${remove_alpha} ${foil_brightness} "${OUTPUT_FOIL4}";

# if [[ ! $FILENAME =~ .*reverse.* ]]; then
# create upscaled, and desaturated version
# echo "🔁 Upscaling & Converting ${file##*/}..."
# convert ${file} -modulate 100x0 -background black -alpha remove -alpha off -brightness-contrast 50x60 -filter Lanczos2 -distort resize x2048 -quality 66 "${OUTPUT_UPSCALED}";
# else
# echo " 🔽 Skipping Reverse Holo ${file##*/}..."
# fi;

done;

echo "┝━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "│ ⇑ ✅ Finish Upscaling / Converting ${FOLDER}"
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

}


# for file in ${FOLDER}/masks/*.png; do

# # get filename for the image
# FILENAME=$( echo "${file##*/}" | cut -f 1 -d '.' );

# # echo "";
# # echo "🔁 Upscaling & Converting ${file##*/}..."
# # echo "";

# # output for 2x masks
# UPSCALE_MASK2="${FOLDER}/masks/upscaled/${FILENAME}_2x.png";
# # output for 4x masks
# UPSCALE_MASK4="${FOLDER}/masks/upscaled/${FILENAME}_4x.png";

# # echo " 🔼 ◼ Creating Mask image @ 2️⃣";
# convert ${UPSCALE_MASK4} -alpha set -background none -channel A -evaluate multiply 8 +channel -colorspace LAB -filter Lanczos2 -distort resize 50% -colorspace sRGB -modulate 100x0 "${UPSCALE_MASK2}";

# output for 1x foils
OUTPUT_FOIL1="${FOLDER}/foils/${FILENAME}.png";
# output for 2x foils
OUTPUT_FOIL2="${FOLDER}/foils/upscaled/${FILENAME}_2x.png";
# output for 4x foils
OUTPUT_FOIL4="${FOLDER}/foils/upscaled/${FILENAME}_4x.png";

echo " ◼ Creating Greyscale image @ 1️⃣";
convert ${file} -modulate 100x0 -background black -alpha remove -alpha off -brightness-contrast 50x60 "${OUTPUT_FOIL1}";

echo " 🔼 ◼ Creating Greyscale image @ 4️⃣";
convert ${UPSCALE_MASK4} -modulate 100x0 -background black -alpha remove -alpha off -brightness-contrast 30x40 "${OUTPUT_FOIL4}";

echo " 🔼 ◼ Creating Greyscale image @ 2️⃣";
convert ${UPSCALE_MASK2} -modulate 100x0 -background black -alpha remove -alpha off -brightness-contrast 30x40 "${OUTPUT_FOIL2}";

# if [[ ! $FILENAME =~ .*reverse.* ]]; then
# create upscaled, and desaturated version
# echo "🔁 Upscaling & Converting ${file##*/}..."
# convert ${file} -modulate 100x0 -background black -alpha remove -alpha off -brightness-contrast 50x60 -filter Lanczos2 -distort resize x2048 -quality 66 "${OUTPUT_UPSCALED}";
# else
# echo " 🔽 Skipping Reverse Holo ${file##*/}..."
# fi;

done;
# done;


# ======================================================================

compress() {

echo "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "╿ ⇄ 🌐 Creating WebP for ${FOLDER}"
echo "├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";
echo "│ ";

shopt -s globstar nullglob;
for file in ${FOLDER}/**/*_2x.png; do

# echo "┝ 🌐 converting ${file} to WebP image";
cwebp "${file}" -m 6 -mt -q 56 -alpha_q 62 -quiet -o "${file%.png}.webp"

done;

echo "┝━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
echo "│ ⇄ ✅ Finish WebP for ${FOLDER}"
echo "└┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈";

}



time (

echo "";
echo "✅ Finish upscaling"
create_directories

shopt -s globstar nullglob;
for file in ${FOLDER}/**/*.png; do
fetch_json
download_images

echo " 🖼 converting ${file} to WebP image";
cwebp "${file}" -m 6 -mt -q 56 -alpha_q 62 -quiet -o "${file%.png}.webp"
upscale
compress

done;
)



Expand Down