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

Resizing to 256x256>, json is 128x128 forced

parent 24f2f5dd
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -51,6 +51,17 @@ for f in * ...@@ -51,6 +51,17 @@ for f in *
do do
# Ignore folders # Ignore folders
if [ -f "$f" ]; then if [ -f "$f" ]; then
# Resizing large images
width=$(identify -format "%w" "$f")> /dev/null
height=$(identify -format "%h" "$f")> /dev/null
if [ $width -gt 256 ]; then
width="256";
fi
if [ $height -gt 256 ]; then
height="256";
fi
echo -n "$f : " echo -n "$f : "
type="png" type="png"
opts="-type TrueColor PNG32:" opts="-type TrueColor PNG32:"
...@@ -66,7 +77,7 @@ do ...@@ -66,7 +77,7 @@ do
echo -n "." echo -n "."
convert "$slug/tmp/$f.$type" -trim +repage "$slug/tmp/$f.$type" convert "$slug/tmp/$f.$type" -trim +repage "$slug/tmp/$f.$type"
echo -n "." echo -n "."
convert -background none -gravity center "$slug/tmp/$f.$type" -resize "128x128>" -extent 128x128 $opts"$slug/tmp/$f.$type" convert -background none -gravity center "$slug/tmp/$f.$type" -resize "${width}x$height" $opts"$slug/tmp/$f.$type"
echo -ne ". \033[92mdone\033[0m! " echo -ne ". \033[92mdone\033[0m! "
# First item in array # First item in array
...@@ -77,15 +88,20 @@ do ...@@ -77,15 +88,20 @@ do
mxc=$(curl -s -X POST -H "Content-Type: image/$type" --data-binary "@$slug/tmp/$f.$type" "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.$type" "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 "."
# Calculating 128x128> format
convert "$slug/tmp/$f.$type" -resize "128x128" "$slug/tmp/size"
width=$(identify -format "%w" "$slug/tmp/size")> /dev/null
height=$(identify -format "%h" "$slug/tmp/size")> /dev/null
# Appending to json # Appending to json
echo -n "{\"body\":\"$f\",\"info\":{\"mimetype\":\"image/$type\",\"h\":128,\"w\":128,\"thumbnail_url\":\"$mxc\"},\"msgtype\":\"m.sticker\",\"url\":\"$mxc\",\"id\":\"$packname-$f\"}" >> "$slug/$slug.json" echo -n "{\"body\":\"$f\",\"info\":{\"mimetype\":\"image/$type\",\"h\":$height,\"w\":$width,\"thumbnail_url\":\"$mxc\"},\"msgtype\":\"m.sticker\",\"url\":\"$mxc\",\"id\":\"$packname-$f\"}" >> "$slug/$slug.json"
first="," first=","
echo -e ". \033[92msuccess\033[0m!" echo -e ". \033[92msuccess\033[0m!"
fi fi
done done
rm "$slug/tmp/size"
montage "$slug/tmp/*"[0] -background none "$slug/preview.png" montage "$slug/tmp/*"[0] -background none "$slug/preview.png"
rm -r "$slug/tmp" # 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