Sprays
I'm far from the voice of authority on this matter, so this is just a "what I've blindly stumbled upon" kinda guide. That said:
Still:
Ideally, when working with stills especially, the image should be square, with each side an exponent of two, typically 512, 256, 128 or 64. This is easily attainable by means of whichever image processing utility you prefer: PS, GIMP, Paintlulwat (I personally use IrFanView as it's my standard viewer anyway and possesses the capabilities).
Once squared, you need to get the image into the Valve Texture Format (.vtf). Personally, I simply use the import spray function in CSS, which, unlike TF2, isn't completely borked. There are many programs available to convert to the format. I have previously used
VTFEdit with some success, the process simply amounting to importing (File > Import) your image and then saving as a .vtf (there are copius options upon importing an image file, none of which I have ever touched but all of which I assume do very fancy and important and clever things).
Animated:
Again, there are many options available when working with animated images. Vandam started a
guide on how to use a program called SprayR, not sure if it was ever finished but I have no experience either way.
The key factor is the 120k filesize limit for sprays. If you can split your .gif into seperate frames, I believe VTFEdit will import multiple images (assuming a uniform resolution and filetype). However, I have no experience of this instance.
My personal preference is a
free online converter. The options can be adjusted to strike a balance between clarity of image and smoothness of motion. As stated, a transparent layer will halve the number of available frames but will prevent black areas being shown on images that are non-square or contain any transparent elements. Resolution selection should be based upon the amount of action in the animation, 128x128 will stutter noticably more due to the lack of frames.
Importing:
VTFEdit spits out a .vtf which can be imported directly using TF2 flawlessly. If importing using an alternate Source game, the .vtf and .vmt need to be copied from the game's \materials\vgui\logos(\UI) folders to TF2's. The online converter will present you with an archive containing the files with folder structure intact, ready to be copied over.
Again, I'm not expert on sprays so feel free to add, amend, critique, lambast, etc. Also, I'm tired so apologies for the gradual decline in quality and coherence of my writings.