u229
Applications Home|Email

 GIFInfo - A vbscript class for reading GIF file properties.

Version 1.2

GIFInfo is an application that lets you read various properties from GIF images. In addition to the more common features such as width, height and color depth, GIFInfo can also read invisible text hidden inside the image. These secret messages are stored in special built-in blocks, without affecting the actual display of the image.

 

An example:

Our example GIF image is the CIA seal which gives us the following information:

File Path: E:\xxxx\xxxxxxx\xxx\stuff\GIFInfo\images\cia.gif
GIF Type: GIF89a
Width: 132
Height: 132
ColorDepth: 8
Image Size: 6808
Date Created: 7/12/2005 11:06:48 AM
Date Last Accessed: 7/12/2005 11:06:48 AM
Date Last Modified: 7/12/2005 11:06:48 AM
Number Of Images: 1
PixelRatio: 0
Application Identifier: GIFInfo!
Application Auth. Code: 49 46 48
Application Data: 72 101 108 108 111 32 87 111 114 108 100 33
Comments: This comment is hidden inside the CIA logo!
Number Of Colors: 128
Colors: 0 0 0, 0 33 66, 0 33 74, 115 132 148, 115 132 156, 115 82 0, 115 99 41, 132 107 33, 132 132 132, 132 148 165, 132 90 0, 140 107 0, 140 115 115, 140 123 24, 140 156 173, 140 41 57, 140 99 90, 153 153 153, 156 115 0, 156 132 24, 156 132 41, 156 173 189, 156 33 57, 156 66 74, 156 90 90, 16 41 66, 16 41 82, 16 8 0, 165 123 107, 165 140 132, 165 16 41, 165 74 90, 165 90 82, 173 132 0, 173 140 16, 173 140 57, 173 148 148, 173 173 173, 173 189 198, 173 24 49, 173 33 57, 181 107 115, 181 107 90, 181 49 66, 181 8 41, 181 82 99, 181 90 82, 189 115 132, 189 123 107, 189 140 0, 189 140 148, 189 148 16, 189 148 33, 189 156 66, 189 165 82, 189 165 99, 189 173 123, 189 181 140, 189 181 156, 189 189 189, 189 198 214, 189 66 74, 189 82 74, 189 90 82, 189 99 115, 198 0 33, 198 115 99, 198 173 165, 198 198 181, 204 153 0, 204 153 153, 204 153 51, 204 204 153, 204 204 204, 206 107 90, 206 123 99, 206 132 107, 206 148 123, 206 156 140, 206 156 16, 206 165 173, 206 165 33, 206 165 8, 206 173 181, 206 189 198, 206 198 173, 206 214 222, 214 123 99, 214 165 16, 214 181 173, 214 206 198, 214 214 214, 222 132 99, 222 165 0, 222 173 16, 222 214 214, 222 222 222, 222 231 239, 231 231 231, 239 132 99, 239 181 0, 239 239 239, 239 247 247, 24 33 74, 247 140 99, 247 181 0, 255 189 0, 255 255 255, 33 24 0, 33 49 57, 33 57 90, 41 66 99, 49 33 0, 49 41 74, 49 74 107, 51 51 51, 66 49 0, 66 74 49, 66 90 107, 66 90 115, 82 33 66, 82 57 0, 82 82 49, 82 99 132, 86 70 82, 99 115 140, 99 66 0, 99 90 41

Notes: The data returned in "Application Auth. Code" and "Application Data" is decimal values. In plain text these characters are: 1.0 and Hello World!.
The RGB triplets returned in the color list are separated by a space character and terminated by a comma. You could build a color palette for the GIF image with these values.

 

How to use the code:

First include the class:

<!--#include file="cGIFInfo.asp"-->

This is how you call the class:

Set oGif = New cGIFInfo

With oGif
    '// Current file path
    .FilePath = "C:\some.gif"
    '// Calling public method
    bSuccess = .GetGIFInfo
    '// GIF87a or GIF89a
    Response.Write "GIF Type: " & .GIFType
    '// Width in pixels
    Response.Write "Width: " & .Width
    '// Height in pixels
    Response.Write "Height: " & .Height
    '// Bits per pixel
    Response.Write "ColorDepth: " & .ColorDepth
    '// Size of image in bytes
    Response.Write "Image Size: " & .ImageSize
    '// Date when file was created/first saved on this server
    Response.Write "Date Created: " & .DateCreated
    '// Date when file was last accessed
    Response.Write "Date Last Accessed: " & .DateLastAccessed
    '// Date when file was last saved to disk
    Response.Write "Date Last Modified: " & .DateLastModified
    '// If this value is bigger than 1, this is an animated GIF
    Response.Write "Number Of Images: " & .NumberOfImages
    '// Width of the pixel divided by the height of the pixel.
    Response.Write "PixelRatio: " & .PixelRatio
    '// Special GIF block: 8 bytes of printable Ascii characters identifying the owner application
    Response.Write "Application Identifier: " & .ApplicationIdentifier
    '// Special GIF block: 3 bytes often used for version information
    Response.Write "Application Auth. Code: " & .ApplicationAuthCode
    '// Special GIF block: Maximum 255 bytes. Unlimited number of blocks can appear in a GIF file.
    Response.Write "Application Data: " & .ApplicationData
    '// Number of unique colors in the GIF image as listed in the Global Color Table.
    Response.Write "Number Of Colors: " & .NumberOfColors
    '// Returns all the colors/RGB triples separated by a space character, finished by a comma (,).
    Response.Write "Colors: " & .Colors
    '// Special GIF block: Maximum 255 bytes. Unlimited number of blocks can appear in a GIF file.
    Response.Write "Comments: " & .Comments
    '// Returns a human readable error message
    If Len(.ErrorMessage) > 0 Then Response.Write .ErrorMessage
End With

Set oGif = Nothing

 

The anatomy of a GIF image - a short introduction.

The GIF Format (Graphics Interchange Format) was first introduced in 1987 by CompuServe and quickly became one of the most popular image file formats on the web. A big drawback for many years was that the use of the file format, until recently, was limited due to copyrights.

There are two different types of a GIF image, GIF87a and GIF89a, where the latter is most common. Only GIF89a supports features like Comment Blocks.

A GIF image can consist of up to 256 colors. It can contain more than one image and is then called an animated GIF. Typically a GIF image consists of a number of different data blocks. These are just a few of them:

Header
Global Color Table
Comment Block
Application Data Block
Image Data

The GIF Reference about Comment Blocks:

"The Comment Extension contains textual information which is not part of the actual graphics in the GIF Data Stream. It is suitable for including comments about the graphics, credits, descriptions or any other type of non-control and non-graphic data. The Comment Extension may be ignored by the decoder, or it may be saved for later processing; under no circumstances should a Comment Extension disrupt or interfere with the processing of the Data Stream."

There is no limitation in the number of Comment Blocks a GIF Image can contain.

The GIF Reference about Application Data Block - which really consists of three parts:

1) "Application Identifier - Sequence of eight printable ASCII characters used to identify the application owning the Application Extension."

2) "Application Authentication Code - Sequence of three bytes used to authenticate the Application Identifier. An Application program may use an algorithm to compute a binary code that uniquely identifies it as the application owning the Application Extension."

3) Application Data

This is an example of how it might look like:

Application Identifier Auth. Code App. Data
8 bytes 3 bytes Max 255 bytes
M Y F O O A P P 1 . 0 App. Data

Of course, not all GIF89a images contain the optional Comment and Application blocks.

 

LINKS:

- For more information on the GIF Format: http://www.w3.org/Graphics/GIF/spec-gif89a.txt
- Another good source: http://semmix.pl/color/exgraf/eeg10.htm
- See also: http://www.u229.no/stuff/GIFFormat/
- Hiding a message inside another message is called Steganography: http://en.wikipedia.org/wiki/Steganography

PRICE:
FREE.

View cGIFInfo.txt

  Download demo project

Therefore: For that or this for it.
© www.u229.no