From ac93ed4d29dd85409fb4c0cd9c2af266e90777c1 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 19 Oct 2024 10:04:14 +0200 Subject: initial commit --- CLI/mysql_db.sh | 25 +++++++++++++++++++++++++ CLI/reduce-image-sizes.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 CLI/mysql_db.sh create mode 100644 CLI/reduce-image-sizes.sh (limited to 'CLI') diff --git a/CLI/mysql_db.sh b/CLI/mysql_db.sh new file mode 100644 index 0000000..e5acfb3 --- /dev/null +++ b/CLI/mysql_db.sh @@ -0,0 +1,25 @@ +# dump +mysqldump -p -u $user $db > $db.sql + +# dump with prefix (https://stackoverflow.com/a/26514699/6114451) +mysqldump -p -u $user $db $(mysql -p -u $user -D $db -Bse "show tables like '$prefix%'") > $prefix.sql +# with date +$(date +"%Y%m%d_%H%M") + +# restore +mysql -p -u $user $db < $db.sql +wp db import $db.sql + +# wp search-replace +wp search-replace "$search" "$replace" --recurse-objects --all-tables --dry-run --export=db.sql +# with date +--export="db$(date +"%Y%m%d_%H%M").sql" + + +# Unicode Fuckups +# set locale pre-export/import to circumvent +export LANG=de_DE.UTF-8 +export LC_ALL=de_DE.UTF-8 +# Links +https://www.ecosia.org/search?q=mysql%20restore%20db%20unicode +https://makandracards.com/makandra/595-dumping-and-importing-from-to-mysql-in-an-utf-8-safe-way diff --git a/CLI/reduce-image-sizes.sh b/CLI/reduce-image-sizes.sh new file mode 100644 index 0000000..3bad2a2 --- /dev/null +++ b/CLI/reduce-image-sizes.sh @@ -0,0 +1,36 @@ +# mogrify -resize 3840x2160 *.jpg + +# jpeg to jpg +find . -type f -iregex ".*\.jpe?g" -exec mogrify -format jpg {} \; + +# resize everything to max 4k +# TODO: also scales up... but shouldn't! +find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g|gif|webp)" -exec mogrify -resize 3840x2160 {} \; +find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g|gif|webp)" -exec mogrify -resize 1920x1080 {} \; +find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g|gif|webp)" -exec mogrify -resize 1200x675 {} \; + +# optimize jpg +find . -type f -iregex ".*\.jpe?g" -exec jpegoptim --strip-all {} \; +find . -type f -iname "*.jpg" -exec jpegoptim --strip-all {} \; + +# optimize png +find . -type f -iname "*.png" -exec optipng -o5 {} \; + +# convert to webp +find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g)" -exec convert {} -quality 90 -define webp:lossless=true $(echo {} | cut -d . -f 1).webp \; + +# add border to image +convert $img.png -background none -bordercolor none -border 20 $img.png + +# square image for favicon +# order of things is important +convert $img -background none -thumbnail 64x64^ -gravity center -extent ${longestside}x${x} $img + +# crop image to size - from center +# https://www.imagemagick.org/discourse-server/viewtopic.php?t=13793 +convert $img -resize 1200x900^ -gravity center -crop 1200x900+0+0 $img + +# svg to png +convert -scale ${x}x${y} -extent 110%x110% -gravity center -background transparent $svg $png +# https://stackoverflow.com/a/12690135 +convert -density 1200 -resize 200x -background none $svg $png -- cgit v1.2.3