Skip to content
Extraits de code Groupes Projets
Valider f10649d2 rédigé par Tigriz's avatar Tigriz
Parcourir les fichiers

Matrixpack: checking if magick and montage transparent + gif support

parent d8dc3c24
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -17,6 +17,12 @@ if test $# != 3 ; then ...@@ -17,6 +17,12 @@ if test $# != 3 ; then
exit 1 exit 1
fi fi
# Checking if ImageMagick is installed
if ! command -v magick &> /dev/null; then
echo "$0:ERROR: magick could not be found"
exit
fi
# Changing directory to work directly in it # Changing directory to work directly in it
cd $3 cd $3
...@@ -32,6 +38,7 @@ echo -e "Creating sticker pack \033[94;1m$packname\033[0m\nhomeserver=\033[94m$h ...@@ -32,6 +38,7 @@ echo -e "Creating sticker pack \033[94;1m$packname\033[0m\nhomeserver=\033[94m$h
# Making result folder # Making result folder
if ! [ -d $slug ]; then mkdir $slug; fi if ! [ -d $slug ]; then mkdir $slug; fi
if ! [ -d "$slug/tmp" ]; then mkdir "$slug/tmp"; fi
echo -n "{\"title\":\"$packname\",\"id\":\"$slug\",\"stickers\":[" > "$slug/$slug.json" echo -n "{\"title\":\"$packname\",\"id\":\"$slug\",\"stickers\":[" > "$slug/$slug.json"
first="" first=""
...@@ -50,11 +57,11 @@ do ...@@ -50,11 +57,11 @@ do
fi fi
# Trim, resize and remove indexed palette from image # Trim, resize and remove indexed palette from image
echo -n "trimming and resizing" echo -n "trimming and resizing"
convert "$f" -bordercolor none -border 1 "$slug/$f" magick convert "$f" -bordercolor none -border 1 "$slug/tmp/$f"
echo -n "." echo -n "."
convert "$slug/$f" -trim +repage "$slug/$f" magick convert "$slug/tmp/$f" -trim +repage "$slug/tmp/$f"
echo -n "." echo -n "."
convert -background none -gravity center "$slug/$f" -resize "128x128>" -extent 128x128 $opts"$slug/$f" magick convert -background none -gravity center "$slug/tmp/$f" -resize "128x128>" -extent 128x128 $opts"$slug/tmp/$f"
echo -ne ". \033[92mdone\033[0m! " echo -ne ". \033[92mdone\033[0m! "
# First item in array # First item in array
...@@ -62,7 +69,7 @@ do ...@@ -62,7 +69,7 @@ do
# Uploading image # Uploading image
echo -n "uploading." echo -n "uploading."
mxc=$(curl -s -X POST -H "Content-Type: image/$type" --data-binary "@$slug/$f" "https://$homeserver/_matrix/media/r0/upload?access_token=$token" | python3 -c "import sys, json; print(json.load(sys.stdin)['content_uri'])") mxc=$(curl -s -X POST -H "Content-Type: image/$type" --data-binary "@$slug/tmp/$f" "https://$homeserver/_matrix/media/r0/upload?access_token=$token" | python3 -c "import sys, json; print(json.load(sys.stdin)['content_uri'])")
echo -n "." echo -n "."
# Appending to json # Appending to json
...@@ -71,9 +78,9 @@ do ...@@ -71,9 +78,9 @@ do
echo -e ". \033[92msuccess\033[0m!" echo -e ". \033[92msuccess\033[0m!"
fi fi
done done
montage -background none "$slug/*.png" "preview.png"
rm $slug/*.png magick montage "$slug/tmp/*"[0] -background none "$slug/preview.png"
mv "preview.png" "$slug" rm -r "$slug/tmp"
echo -ne "# $packname \n![Preview of $packname](preview.png)" > "$slug/README.md" echo -ne "# $packname \n![Preview of $packname](preview.png)" > "$slug/README.md"
echo -n "]}" >> "$slug/$slug.json" echo -n "]}" >> "$slug/$slug.json"
cd - > /dev/null cd - > /dev/null
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter