add file
This commit is contained in:
		
							
								
								
									
										77
									
								
								scpt/convert.zsh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										77
									
								
								scpt/convert.zsh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| #!/bin/zsh | ||||
| d=${0:a:h} | ||||
| dd=${0:a:h:h} | ||||
|  | ||||
| echo "1 : [d]efault(no), [b]lack, [s]ilver" | ||||
| read | ||||
|  | ||||
| url=syui.ai/img | ||||
|  | ||||
| case $OSTYPE in | ||||
| 	darwin*) | ||||
| 		path_nvm_sh="/opt/homebrew/opt/nvm/nvm.sh";; | ||||
| 	linux*) | ||||
| 		path_nvm_sh="";; | ||||
| esac | ||||
|  | ||||
| dir=$dd/public/card | ||||
| static=$dd/public/static/img | ||||
| json=$dd/public/json/card.json | ||||
| mkdir -p $dir | ||||
| mkdir -p $static | ||||
| n=`cat $json|jq "length"` | ||||
| n=`expr $n - 1` | ||||
|  | ||||
| case $1 in | ||||
| 	silver|s) | ||||
| 		bg=$static/card_bg_silver.png | ||||
| 		br=$static/card_br.png | ||||
| 		;; | ||||
| 	black|b) | ||||
| 		bg=$static/card_bg_black.png | ||||
| 		br=$static/card_br.png | ||||
| 		;; | ||||
| 	default|d|*) | ||||
| 		bg=$static/card_bg.png | ||||
| 		br=$static/card_br.png | ||||
| 		;; | ||||
| esac | ||||
|  | ||||
| cd $dir | ||||
| export NVM_DIR="$HOME/.nvm" | ||||
| [ -s "$path_nvm_sh" ] && \. "$path_nvm_sh" | ||||
| nvm use 17 | ||||
| nvm i squoosh-cli | ||||
|  | ||||
| for ((i=0;i<=$n;i++)) | ||||
| do | ||||
| 	p=`cat $json|jq -r ".[$i].p"` | ||||
| 	sid=`cat $json|jq -r ".[$i].src"` | ||||
| 	s=$static/${sid}.png | ||||
| 	id=`cat $json|jq -r ".[$i].id"` | ||||
| 	o=$dir/card_$id.png | ||||
|  | ||||
| 	if [ -f $o ];then | ||||
| 		continue | ||||
| 	fi | ||||
|  | ||||
| 	if [ ! -f $s ];then | ||||
| 		curl -sL $url/yui_${sid}.png -o $s | ||||
| 	fi | ||||
|  | ||||
| 	if [ ! -f $o ] && [ -n "`echo $s|grep ai_model`" ];then | ||||
| 		model_card=$dir/${sid}.png | ||||
| 		model_webp=$dir/${sid}.webp | ||||
| 		cp -rf $model_card $o | ||||
| 		squoosh-cli --webp '{"quality":100}' -d ./ --resize '{width:825,height:1080}' $o | ||||
| 	fi | ||||
|  | ||||
| 	if [ ! -f $o ];then | ||||
| 	#if [ ! -f $o ] && [ -z "`echo $s|grep ai_model`" ];then | ||||
| 		composite -gravity north  -geometry +0+160 -compose over $s $bg $o.back | ||||
| 		composite -gravity north  -geometry +0+0 -compose over $br $o.back $o | ||||
| 		squoosh-cli --webp '{"quality":100}' -d ./ --resize '{width:825,height:1080}' $o | ||||
| 		rm $o.back | ||||
| 	fi | ||||
| 	 | ||||
| done | ||||
							
								
								
									
										57
									
								
								scpt/ogimage.zsh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										57
									
								
								scpt/ogimage.zsh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| #!/bin/zsh | ||||
|  | ||||
| url=https://card.syui.ai | ||||
| d=${0:a:h} | ||||
| dd=${0:a:h:h} | ||||
| dir=$dd/public/card | ||||
| o_dir=$dd/public/static/img | ||||
| static=$dd/public/static/img | ||||
| json=$dd/public/json/card.json | ||||
| mkdir -p $dir | ||||
| mkdir -p $static | ||||
| n=`cat $json|jq "length"` | ||||
| n=`expr $n - 1` | ||||
|  | ||||
| for ((i=0;i<=$n;i++)) | ||||
| do | ||||
| 	p=`cat $json|jq -r ".[$i].p"` | ||||
| 	h=`cat $json|jq -r ".[$i].h"` | ||||
| 	sid=`cat $json|jq -r ".[$i].src"` | ||||
| 	s=$static/${sid}.png | ||||
| 	id=`cat $json|jq -r ".[$i].id"` | ||||
| 	o=$dir/card_$id.png | ||||
| 	oo=$o_dir/og_${id}.png | ||||
| 	o_url=$url/card/og_${id}.png | ||||
| 	index=$o_dir/$id/index.html | ||||
|  | ||||
| 	if [ ! -f $oo ];then | ||||
| 		echo $oo | ||||
| 		convert $o -gravity center -extent 8000x4000 $oo | ||||
| 	fi | ||||
|  | ||||
| #	mkdir -p $o_dir/$id | ||||
| # | ||||
| #echo ' | ||||
| #<!DOCTYPE html> | ||||
| #<html lang="en"> | ||||
| #<head> | ||||
| #<title>card.syui.ai</title><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>card.syui.ai</title><link href="app.css" rel="preload" as="style"><link href="app.js" rel="preload" as="script"><link href="chunk-vendors.js" rel="preload" as="script"><link href="app.css" rel="stylesheet"> | ||||
| #<meta name="twitter:card" content="summary"> | ||||
| #<meta property="og:url" content="https://card.syui.ai"> | ||||
| #' >! $index | ||||
| # | ||||
| #echo " | ||||
| #<meta property=\"og:title\" content=\"$h\"> | ||||
| #<meta property=\"og:description\" content=\"$p\"> | ||||
| #<meta property=\"og:image\" content=\"$o_url\"> | ||||
| #" >> $index | ||||
| # | ||||
| #echo ' | ||||
| #</head> | ||||
| #<body> | ||||
| #<div id="app"></div><script src="chunk-vendors.js"></script><script src="app.js"></script> | ||||
| #</body> | ||||
| #</html> | ||||
| #' >> $index | ||||
|  | ||||
| done | ||||
		Reference in New Issue
	
	Block a user