You don't have to change it to a GIF87a. All you need to do is strip the offending GCE block out of the file. (Unless you have found a
really ancient GIF decoder that you
must use, you can safely assume that all GIF decoders can handle a GIF89a.)
You might find my old
gifblock package (for
Tcl) useful. With it you can load, modify, and save the blocks of a GIF very easily.
http://wiki.tcl.tk/16127
The complete GIF89a specification can be found here
http://www.w3.org/Graphics/GIF/spec-gif89a.txt
The only difference between the 87a and 89a formats is the introduction of a number of extension blocks, such as the GCE (and, of course, the fifth byte of the file is a '9' instead of a '7').
If you don't have Tcl, you can get something quick and easy to use here
http://code.google.com/p/tclkit/
Just download and save the executable file (say tclkitsh-8.5.9-win32.upx.exe ). You might want to name it something easier to type, like "tclsh.exe". Save the "gifblock.tcl" file I linked for you in the same place as you did the executable. Also save this as "
nogce.tcl" in the same place:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
source gifblock.tcl
namespace import gifblock::*
# Make sure the user gave the proper arguments
if {$argc != 2} {
puts "usage:\n $argv0 ORIGINAL.gif MODIFIED.gif\n"
puts {Removes all instances of the GCE from the ORIGINAL GIF file}
puts {and saves the changes as the MODIFIED GIF file.}
exit
}
# Load the GIF data
if {[catch {gif.load gifdata [lindex $argv 0]} msg]} {
puts $msg
exit 1
}
puts {Original GIF}
foreach name [gif.blocknames gifdata] { puts " $name" }
# Remove the GCE blocks
set ns [gif.index gifdata {Graphic Control} 0]
foreach n [lreverse $ns] {
set gifdata [lreplace $gifdata $n $n]
}
puts {Modified GIF}
foreach name [gif.blocknames gifdata] { puts " $name" }
# Save the modified file
if {[catch {gif.save gifdata [lindex $argv 1]} msg]} {
puts $msg
exit 2
}
puts Done
|
Then, from the command prompt, run the program, substituting your own filenames of course:
C:\tcl> tclsh nogce.tcl image-to-modify.gif modified-image.gif |
Assuming all went well you should see output something like
Original GIF
GIF Header
Color Table
Logical Screen Descriptor
Graphic Control
Image Descriptor
Modified GIF
GIF Header
Color Table
Logical Screen Descriptor
Image Descriptor
done
|
Hope this helps.
[edit] Fixed an error