Menu ▾ ▴

#9 Fix for Bug in PluginGIF.cpp

closed
None
5
2012-10-31
2006-07-10
Anonymous
No

I just found and fixed a bug in the GIF-Plugin of
FreeImage. In line 1153 of PluginGIF.cpp (v3.9) an
Application data extension block with a wrong block
size is written:

"x21\xFF\x0BNETSCAPE2.0\x03\x01" followed by 2 NULL-bytes

instead of

"x21\xFF\x0FNETSCAPE2.0\x03\x01"

Most GIF-implementations don't care about this flaw,
but Sun Java chokes on GIFs created by FreeImage.

Greetings
Arnold Konrad
arnold.konrad@dynamicmedia.at

Discussion

  • Ryan Rubley

    Ryan Rubley - 2006-07-10

    Logged In: YES
    user_id=505740

    There is no bug in FreeImage here, in fact, your suggestion
    cleraly violates the GIF89a specification. For the Extension
    (0x21) of type Application (0xFF) it is defined that the
    ONLY valid block size is 11 (0x0B) and the first 8 bytes are
    the Application Identifier (NETSCAPE) and the next 3 bytes
    are the Application Authentication Code (2.0).

    This block is defined to contain subblocks of various
    lengths, followed by a single 0x00 byte to mark the end of
    the data subblocks.

    The only data subblock given in this particular application
    extension is 3 bytes long (0x03) and the value 0x01 marks
    this subblock as containing the repeat counter information.
    The next two bytes of the subblock are the repeat value.
    After this follows the subblock terminator null byte.

     
  • Nobody/Anonymous

    Logged In: NO

    This comes from reading only half the spec :). You're right
    of course. We have to use quite outdated Java components for
    compatibility-reasons, that aren't able to load animated GIFs.
    For these components, the NETSCAPE-extension indicates an
    animated GIF that won't be loaded. If I strip out the
    extension completely, it works just fine. Our app doesn't
    support animated GIFs anyway :).

    btw: Is there a special reason for writing this extension
    block for all GIF-images, not just animated ones?

     
  • Ryan Rubley

    Ryan Rubley - 2006-07-11

    Logged In: YES
    user_id=505740

    The NETSCAPE2.0 extension is written to set the value for
    the Loop metadata, which defaults to 0. If you set Loop to
    1, the extension will not be written. This could be used as
    a work-around for your buggy Java compenent if you need the
    extension removed. FreeImage currently only writes GIF89a
    into the header, and any GIF decoder which accepts a GIF89a
    header MUST be prepared to at the very least know how to
    skip over all extension blocks it doesn't care about, which
    is very easy to do with all the length headers.

    If your Java component can only read GIF87a files, where the
    Application Extension block was not yet defined, then it
    should throw a warning or error when encountering a GIF89a
    file. One change which could be made to FreeImage might be
    to save GIF89a files when saving single-frame animations,
    but this may have a lot of changes needed to ensure other
    metadata doesn't get written to GIF87a files where it would
    be invalid. This would eliminate any ability to set things
    such as Loop, and thus never write the NETSCAPE2.0 block for
    single-frame GIFs.

     
  • Nobody/Anonymous

    Logged In: NO

    Your suggested workaround works perfectly well. Thanks for
    your great help!

    Greetings
    Arnold Konrad

     
  • Hervé Drolon

    Hervé Drolon - 2006-07-13

    Logged In: YES
    user_id=613758

    As the fix is invalid, this tracker will be closed
    automatically in 15 days, unless someone wants to add
    something.

    Hervé Drolon

     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     

Anonymous
Anonymous

Add attachments
Cancel