I was confused by that too, by just putting "convert" it's implied you'll use ImageMagick?
Yes the convert command will use ImageMagick.
I don't know what you mean exactly, but I had an issue in which b10 would come before b2, both in bulk renamer and with the
convert stuff.
[collapse=Bulk Renamer putting 10 before the 2]
[/collapse]
I fixed that by making all numbers after the
b have three digits: b001, b002, b003 ..., instead of b1, b2, b3 ....
That way it would only mess up if you have a move that's 4-digit long.
Yes that's the problem.
Code:
echo b*.jpg
b10.jpg b11.jpg b12.jpg b13.jpg b14.jpg b15.jpg b16.jpg b17.jpg b18.jpg b19.jpg b1.jpg b20.jpg b21.jpg b22.jpg b23.jpg b24.jpg b25.jpg b26.jpg b27.jpg b28.jpg b29.jpg b2.jpg b30.jpg b31.jpg b32.jpg b33.jpg b34.jpg b35.jpg b36.jpg b37.jpg b38.jpg b39.jpg b3.jpg b40.jpg b41.jpg b42.jpg b43.jpg b44.jpg b4.jpg b5.jpg b6.jpg b7.jpg b8.jpg b9.jpg
And you can see that they're not properly sorted. There are two solutions. Solution #1 : Either rename every file with leading zeros (but I didn't want to change your original setup). However solution #2 implies you're using bash. Solution #2a : get the number of files, loop a number of times equals to the number of files, print the "b" + increment + ".jpg".
Code:
NBR_FRAMES=$(echo b*.jpg | wc -w); for (( i=1; $i <= $NBR_FRAMES; $((i++)) )); do echo -n b"$i".jpg \ ; done; unset NBR_FRAMES
b1.jpg b2.jpg b3.jpg b4.jpg b5.jpg b6.jpg b7.jpg b8.jpg b9.jpg b10.jpg b11.jpg b12.jpg b13.jpg b14.jpg b15.jpg b16.jpg b17.jpg b18.jpg b19.jpg b20.jpg b21.jpg b22.jpg b23.jpg b24.jpg b25.jpg b26.jpg b27.jpg b28.jpg b29.jpg b30.jpg b31.jpg b32.jpg b33.jpg b34.jpg b35.jpg b36.jpg b37.jpg b38.jpg b39.jpg b40.jpg b41.jpg b42.jpg b43.jpg b44.jpg
Solution #2b : Use the sort command with -V option. Since sort has to work with newline separated words, I just use the tr command to change it to \n-separated and then back to space-separated.
Code:
echo b*.jpg | tr ' ' "\n" | sort -V | tr "\n" ' '
b1.jpg b2.jpg b3.jpg b4.jpg b5.jpg b6.jpg b7.jpg b8.jpg b9.jpg b10.jpg b11.jpg b12.jpg b13.jpg b14.jpg b15.jpg b16.jpg b17.jpg b18.jpg b19.jpg b20.jpg b21.jpg b22.jpg b23.jpg b24.jpg b25.jpg b26.jpg b27.jpg b28.jpg b29.jpg b30.jpg b31.jpg b32.jpg b33.jpg b34.jpg b35.jpg b36.jpg b37.jpg b38.jpg b39.jpg b40.jpg b41.jpg b42.jpg b43.jpg b44.jpg
________________________________________
If that can be fixed easily, I could totally make a few characters that way. We'll have to agree upon some fixed optimal delay though.
By the way, is this convert program installed by default on ubuntu? That's what surprised me, I thought I'd first have to install something, but no, it worked right away.
If you have ubuntu installed, it's great since you can actually use my scripts. I'm not sure if ImageMagick is installed by default. Maybe you installed something else that needed it and through dependancies it got installed? Anyways, since it's in the default repository, it's only "sudo apt-get install imagemagick" away.
This is the most recent version of my script.
Code:
#!/usr/bin/env bash
#hitbox2anim
function convertJPG2GIF {
NBR_FRAMES=$(echo b*.jpg | wc -w)
if [[ "$NBR_FRAMES" -eq 0 ]]; then
echo "Hitbox images needs to start with the letter 'b'; None were found in ${PWD%/*}." >&2
exit 1
else
CHAR="${PWD%/*}"
CHAR="${CHAR##*/}"
ATT="${PWD##*/}"
echo "Converting character: $CHAR, attack: $ATT, number of frames : $NBR_FRAMES..."
convert -delay 5 -layers optimize $(for (( i=1; $i <= $NBR_FRAMES; $((i++)) )); do echo -n b"$i".jpg \ ; done) b.gif
echo "Done."
fi
}
if [[ $# -eq 0 ]]; then
convertJPG2GIF
else
while [[ $# -gt 0 ]]; do
cd "$1"
convertJPG2GIF
cd - > /dev/null
shift
done
fi
If you want to test it, Sangoku, copy and paste it in any text editor. Save as "hitbox2anim". Use
chmod u+x hitbox2anim to give it execute permission.
It works in two ways. First, you can move the file hitbox2anim in the folder with all the frames pictures and from the command line just type :
./hitbox2anim. It will create b.gif.
Second, you can pass the folders which contains the frame pictures as arguments. For example, if my folder which contains the yoshi images is : /FrameDisplay/yoshi/, you just have to use
./hitbox2anim /FrameDisplay/yoshi/*/. And that's it. It's going to convert every yoshi's attack into b.gif files. (They will be in the corresponding folder, e.g. /FrameDisplay/yoshi/2a/b.gif).
Once you're done, you can create a folder (
mkdir /FrameDisplay/yoshi/gif/) and move every GIF's into that folder. (You need to be in the
/FrameDisplay/yoshi/ folder for the following to work.
Code:
for file in ./*/b.gif; do parent="${file%/*}" && parent="${parent##*/}"; mv "$file" ./gif/"$parent".gif; done; unset parent; unset file
Every b.gif file will be moved to a /gif/ folder and will be renamed with the parent folder's name. E.g. yoshi/2a/b.gif will be renamed (and moved) yoshi/gif/2a.gif.
Things to agree on : frame delay. And if we want to have gifs to be the superposition of the hitbox display and normal display, we have to agree on the best transparency of the overlay image.