diff --git a/matrixpack.sh b/matrixpack.sh
index 0c63eb2ed5fabd55a9ec8a7f2894172c9b53ce5d..eea7727a481be7212f626513f04a8ae6f723e64c 100755
--- a/matrixpack.sh
+++ b/matrixpack.sh
@@ -17,6 +17,12 @@ if test $# != 3 ; then
   exit 1
 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
 cd $3
 
@@ -32,6 +38,7 @@ echo -e "Creating sticker pack \033[94;1m$packname\033[0m\nhomeserver=\033[94m$h
 
 # Making result folder
 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"
 
 first=""
@@ -50,11 +57,11 @@ do
     fi
     # Trim, resize and remove indexed palette from image
     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 "."
-    convert "$slug/$f" -trim +repage "$slug/$f"
+    magick convert "$slug/tmp/$f" -trim +repage "$slug/tmp/$f"
     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! "
     
     # First item in array
@@ -62,7 +69,7 @@ do
     
     # Uploading image
     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 "."
 
     # Appending to json
@@ -71,9 +78,9 @@ do
     echo -e ". \033[92msuccess\033[0m!"
   fi
 done
-montage -background none "$slug/*.png" "preview.png"
-rm $slug/*.png
-mv "preview.png" "$slug"
+
+magick montage "$slug/tmp/*"[0] -background none "$slug/preview.png"
+rm -r "$slug/tmp"
 echo -ne "# $packname  \n![Preview of $packname](preview.png)" > "$slug/README.md"
 echo -n "]}" >> "$slug/$slug.json"
 cd - > /dev/null