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

Fix conversion when not trusted

parent 7c4d7d26
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#!/bin/bash #!/bin/bash
# TODO:
# Scale up, not only down
# Fail on remove empty sticker pack dir
# Test trusted source
shopt -s nocasematch # Case insensitive shopt -s nocasematch # Case insensitive
STPKG_CONF_FILE=~/.config/stpkg.sh STPKG_CONF_FILE=~/.config/stpkg.sh
...@@ -632,29 +637,40 @@ process_sticker_file() { ...@@ -632,29 +637,40 @@ process_sticker_file() {
# Convert animated image # Convert animated image
# #
local DEST_TYPE=$STPKG_ANIMATED_TARGET_FILETYPE local DEST_TYPE=$STPKG_ANIMATED_TARGET_FILETYPE
local BONUS_OPT="" local DEST_EXT=$(file_get_ext_from_type "$DEST_TYPE")
convert "${FILE}" -coalesce -background none -trim -layers TrimBounds "$DEST_EXT:${TEMP}" 1>&2 \
&& progress_dot \
|| die "$NAME failed trimming the sticker"
convert "${TEMP}" -coalesce -dispose Background -resize ${DEST_WIDTH}x${DEST_HEIGHT} "$DEST_EXT:${TEMP}" 1>&2 \
&& progress_dot \
|| die "$NAME failed resizing the sticker"
#convert "${TEMP}" -coalesce -layers OptimizePlus -layers RemoveDups -layers OptimizeTransparency "$DEST_EXT:${TEMP}" 1>&2 \
convert "${TEMP}" -coalesce -layers Optimize "$DEST_EXT:${TEMP}" 1>&2 \
&& progress_dot \
|| die "$NAME failed optimizing the sticker"
else else
# #
# Convert fixed image # Convert fixed image
# #
local DEST_TYPE=$STPKG_IMAGE_TARGET_FILETYPE local DEST_TYPE=$STPKG_IMAGE_TARGET_FILETYPE
local BONUS_OPT="-trim +repage"
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 ${BONUS_OPT} -background none -gravity center -resize ${DEST_WIDTH}x${DEST_HEIGHT} "${DEST_EXT}:${TEMP}" 1>&2 \
convert "$FILE" -bordercolor none -border 1 -background none -gravity center -trim +repage -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"
fi
DEST_WIDTH=$(file_get_width "$TEMP")
DEST_HEIGHT=$(file_get_height "$TEMP")
fi fi
# TODO: get real width/height from generated file # TODO: check for gifs here
DEST_WIDTH=$(file_get_width "$TEMP")
DEST_HEIGHT=$(file_get_height "$TEMP")
# Upload the transformed file # Upload the transformed file
local MXC=$(__upload_file "$DEST_TYPE" "$TEMP" "$NAME") local MXC=$(__upload_file "$DEST_TYPE" "$TEMP" "$NAME")
rm "$TEMP"
progress_dot progress_dot
JSON_REF=$(create_sticker_json "$PACK_NAME" "$NAME" "$DEST_WIDTH" "$DEST_HEIGHT" "$DEST_TYPE" "$MXC") JSON_REF=$(create_sticker_json "$PACK_NAME" "$NAME" "$DEST_WIDTH" "$DEST_HEIGHT" "$DEST_TYPE" "$MXC")
......
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