Skip to content
Extraits de code Groupes Projets
Valider 7c4d7d26 rédigé par Elliu's avatar Elliu
Parcourir les fichiers

Bugfix

parent 267b8cf5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -5,7 +5,7 @@ shopt -s nocasematch # Case insensitive ...@@ -5,7 +5,7 @@ shopt -s nocasematch # Case insensitive
STPKG_CONF_FILE=~/.config/stpkg.sh STPKG_CONF_FILE=~/.config/stpkg.sh
BASE_DIR="$PWD" BASE_DIR="$PWD"
animatedFiletype=(gif apng) declare -A animatedFiletype=(gif apng)
# Detect install # Detect install
if [ "x$1" = "x-install" ]; then if [ "x$1" = "x-install" ]; then
...@@ -56,7 +56,7 @@ require() { ...@@ -56,7 +56,7 @@ require() {
} }
require \ require \
md5sum mktemp column uuidgen convert montage identify python3 curl \ md5sum mktemp column uuidgen convert montage identify python3 curl \
sed tr git sponge ls find jq chmod cat expr iconv sed tr git sponge ls find jq chmod cat expr iconv bc
__grep=`which egrep` __grep=`which egrep`
if [ -z $__grep ]; then if [ -z $__grep ]; then
__grep=`which grep` __grep=`which grep`
...@@ -175,7 +175,7 @@ __upload_file() { ...@@ -175,7 +175,7 @@ __upload_file() {
local NAME=$3 # The pretty name for the sticker local NAME=$3 # The pretty name for the sticker
# TODO: Use jq here # TODO: Use jq here
curl -s -X POST -H \ curl -s -X POST -H \
"Content-Type: image/$TYPE" --data-binary "@$DEST" "https://$STPKG_HOMESERV/_matrix/media/r0/upload?access_token=$STPKG_TOKEN" | \ "Content-Type: $TYPE" --data-binary "@$FILE" "https://$STPKG_HOMESERV/_matrix/media/r0/upload?access_token=$STPKG_TOKEN" | \
tee /tmp/toto | python -c "import sys, json; print(json.load(sys.stdin)['content_uri'])" tee /tmp/toto | python -c "import sys, json; print(json.load(sys.stdin)['content_uri'])"
[ $? -ne 0 ] && die "Failed to upload sticker $NAME for pack $PACK_NAME to $STPKG_HOMESERV" [ $? -ne 0 ] && die "Failed to upload sticker $NAME for pack $PACK_NAME to $STPKG_HOMESERV"
} }
...@@ -274,6 +274,9 @@ STPKG_MAX_WIDTH=256 ...@@ -274,6 +274,9 @@ STPKG_MAX_WIDTH=256
STPKG_GENERATE_PREVIEW="no" STPKG_GENERATE_PREVIEW="no"
STPKG_IMAGE_TARGET_FILETYPE="png" STPKG_IMAGE_TARGET_FILETYPE="png"
STPKG_ANIMATED_TARGET_FILETYPE="gif" STPKG_ANIMATED_TARGET_FILETYPE="gif"
__do_mount() { :; }
EOF EOF
chmod 00600 $STPKG_CONF_FILE chmod 00600 $STPKG_CONF_FILE
...@@ -578,8 +581,8 @@ process_sticker_file() { ...@@ -578,8 +581,8 @@ process_sticker_file() {
local INIT_WIDTH=$(file_get_width "$FILE") local INIT_WIDTH=$(file_get_width "$FILE")
local INIT_HEIGHT=$(file_get_height "$FILE") local INIT_HEIGHT=$(file_get_height "$FILE")
local WIDTH_RATIO="$(echo "scale=10; $INIT_WIDTH/$STPKG_MAX_WIDTH")" local WIDTH_RATIO="$(echo "scale=10; $INIT_WIDTH/$STPKG_MAX_WIDTH" | bc)"
local HEIGHT_RATIO="$(echo "scale=10; $INIT_HEIGHT/$STPKG_MAX_HEIGHT")" local HEIGHT_RATIO="$(echo "scale=10; $INIT_HEIGHT/$STPKG_MAX_HEIGHT" | bc)"
if [ $(echo "$HEIGHT_RATIO >= $WIDTH_RATIO" | bc) = "1" ]; then if [ $(echo "$HEIGHT_RATIO >= $WIDTH_RATIO" | bc) = "1" ]; then
if [ $(echo "$HEIGHT_RATIO > 1" | bc) = "1" ]; then if [ $(echo "$HEIGHT_RATIO > 1" | bc) = "1" ]; then
...@@ -589,18 +592,17 @@ process_sticker_file() { ...@@ -589,18 +592,17 @@ process_sticker_file() {
local DEST_HEIGHT=$INIT_HEIGHT local DEST_HEIGHT=$INIT_HEIGHT
local DEST_WIDTH=$INIT_WIDTH local DEST_WIDTH=$INIT_WIDTH
fi fi
else elif [ $(echo "$WIDTH_RATIO > 1" | bc) = "1" ]; then
if [ $(echo "$WIDTH_RATIO > 1" | bc) = "1" ]; then
local DEST_HEIGHT="" local DEST_HEIGHT=""
local DEST_WIDTH=$STPKG_MAX_WIDTH local DEST_WIDTH=$STPKG_MAX_WIDTH
else else
local DEST_HEIGHT=$INIT_HEIGHT local DEST_HEIGHT=$INIT_HEIGHT
local DEST_WIDTH=$INIT_WIDTH local DEST_WIDTH=$INIT_WIDTH
fi fi
fi
# Get the names and extensions # Get the names and extensions
local INIT_TYPE=$(file_get_type "$FILE") local INIT_TYPE=$(file_get_type "$FILE")
local INIT_EXT=$(file_get_ext_from_type "$INIT_TYPE")
local NAME=$(file_get_name "$FILE") local NAME=$(file_get_name "$FILE")
local TEMP=`mktemp --suffix=.stpkg` local TEMP=`mktemp --suffix=.stpkg`
...@@ -625,7 +627,7 @@ process_sticker_file() { ...@@ -625,7 +627,7 @@ process_sticker_file() {
progress_dot progress_dot
else else
if [[ ${animatedFiletype[$INIT_TYPE]} ]]; then if [[ ${animatedFiletype[$INIT_EXT]} ]]; then
# #
# Convert animated image # Convert animated image
# #
...@@ -637,11 +639,11 @@ process_sticker_file() { ...@@ -637,11 +639,11 @@ process_sticker_file() {
# Convert fixed image # Convert fixed image
# #
local DEST_TYPE=$STPKG_IMAGE_TARGET_FILETYPE local DEST_TYPE=$STPKG_IMAGE_TARGET_FILETYPE
local BONUS_OPT="+repage" local BONUS_OPT="-trim +repage"
fi fi
local DEST_EXT=$(file_get_ext_from_type "$DEST_TYPE") local DEST_EXT=$(file_get_ext_from_type "$DEST_TYPE")
convert "$FILE" -bordercolor none -border 1 -background none -gravity center -resize ${DEST_WIDTH}x${DEST_HEIGHT} ${BONUS_OPT} "${DEST_EXT}:${TEMP}" 1>&2 \ convert "$FILE" -bordercolor none -border 1 ${BONUS_OPT} -background none -gravity center -resize ${DEST_WIDTH}x${DEST_HEIGHT} "${DEST_EXT}:${TEMP}" 1>&2 \
&& progress_dot \ && progress_dot \
|| die "$NAME failed converting the sticker" || die "$NAME failed converting the sticker"
...@@ -781,7 +783,7 @@ __pack() { ...@@ -781,7 +783,7 @@ __pack() {
# For the report # For the report
[ "x$FIRST_IN_ARRAY" = "x" ] && echo -e "StickerName MXC Type Width Height" [ "x$FIRST_IN_ARRAY" = "x" ] && echo -e "StickerName MXC Type Width Height"
local FIRST_IN_ARRAY="," local FIRST_IN_ARRAY=","
echo -e "$ST_JSON" | jq '[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")' echo -e "$ST_JSON" | jq -r '[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")'
progress_reset progress_reset
done | column -t done | column -t
...@@ -900,7 +902,7 @@ __do_command() { ...@@ -900,7 +902,7 @@ __do_command() {
*) *)
;; ;;
esac esac
$* __$*
} }
###################### ######################
......
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