diff --git a/stpkg b/stpkg
index 275b14ac54153cc38a8fffe17b7719282cbefb39..6d960250a122def30f8c0ba28ba99a9e5d95692a 100755
--- a/stpkg
+++ b/stpkg
@@ -1,5 +1,10 @@
 #!/bin/bash
 
+# TODO:
+# Scale up, not only down
+# Fail on remove empty sticker pack dir
+# Test trusted source
+
 shopt -s nocasematch    # Case insensitive
 
 STPKG_CONF_FILE=~/.config/stpkg.sh
@@ -632,29 +637,40 @@ process_sticker_file() {
             # Convert animated image
             #
             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
             #
             # Convert fixed image
             #
             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 \
-            && progress_dot \
-            || die "$NAME failed converting the sticker"
+            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 \
+                || die "$NAME failed converting the sticker"
+        fi
 
-        DEST_WIDTH=$(file_get_width "$TEMP")
-        DEST_HEIGHT=$(file_get_height "$TEMP")
     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
     local MXC=$(__upload_file "$DEST_TYPE" "$TEMP" "$NAME")
+    rm "$TEMP"
     progress_dot
 
     JSON_REF=$(create_sticker_json "$PACK_NAME" "$NAME" "$DEST_WIDTH" "$DEST_HEIGHT" "$DEST_TYPE" "$MXC")