GIF animations are included in HTML documents using the IMG tag. Therefore, a simple way to remove GIF animations would be to create a ContentFilter to remove all IMG tags. However, the IMG tag is used to include all types of images so removing IMG will filter out all images. In order to only filter out animations, a ContentFilter must be used to scan the bytes in all GIF images and look for the GIF animation extension signature. This signature, shown in Figure 5.2, is the sequence of 19 bytes used to specify the number of times the animation should repeat.
When this signature is found, a filter can modify the signature bytes to change the behavior of the animation. For example, a filter can change the repeat count bytes to force an animation that would repeat forever to repeat only once. Another action that can be taken by a filter is to either remove the signature or change the animation signature to that of the GIF Comment Extension signature. This will alter the image to ensure that it will not be seen as an animation and only a single frame will be displayed inside the web browser. Either changing the repeat count or signature still requires that the entire animation be downloaded. To prevent the downloading of GIF animations, a filter can truncate the image to zero length by not sending any bytes for the animation to the object stream. The downside to doing this is that the web browser will display a broken image icon for the image.