There have been image exploits before, I remember a libjpeg exploit on Windows long since patched (I couldn't find it easily).
The way programs work, there is an area called the stack (and less so, a place called the heap) where data and code are somewhat mixed. If I can give you data in a different format and/or size than what you are prepared to take, maybe I can really mix my data into your code and make it code. Meaning, I con you to run me instead of your program. Now, instead of running Internet Explorer (or whatever) you're running me, scary.
Technically this wouldn't be a virus - it spread as a trojan. But it doesn't matter much how it got on your system, you're running it.
There are some limits. There has to be a bug in the reading code. Its non-trivial to get the code to run. You need to know assembler and how to call Windows code from it. Windows and other OS's have made efforts to make actually using these bugs harder and harder (though very smart people still can).
Keep your system updated. Much of the damage is from bugs, they can be patched.
What was in the torrent package? A video? An executable? An executable doesn't even need to 'hack' your system, you just ran it, gave it permission. Videos are much more complicated than a gif. Much more likely to have bugs in code that lead to exploits. A gif is a simple file format, code has been around before the web existed, fewer holes for bugs. New video codecs come out all the time. Windows WMV files used to/still can (not sure) call out to web pages for ads or codecs. Many of these webpages have IE exploits and you just pwned your computer. I'd be much more worried about what else was in the torrent than the gifs.