You can use the gifsicle to solve this problem. It's a command line program created for manipulate/create gif's.You can see more information at: http://www.lcdf.org/gifsicle/