Top Documents Download Gallery Repository
Are you looking for a Software Engineer? Check Here

21gif Module

The gif module provides measures to read/write image data in GIF format. To utilize it, import the gif module using import function.

Below is an example to read a GIF file:

import(gif)
img = image('foo.gif')

Below is an example to create a GIF file that contains multiple images:

import(gif)
g = gif.content()
g.addimage(['cell1.png', 'cell2.png', 'cell3.png'], 10) g.write('anim.gif')

21.1Exntension to Function's Capability

This module extends the capability of function image() and instance method image#write() so that they can read/write GIF files.

When function image() is provided with a stream that satisfies the following conditions, it would recognize the stream as a GIF file.

When instance method image#write() is provided with a stream that satisfies the following condition, it would write image data in GIF format.

21.2gif.content Class

The gif.content class provides properties to explain GIF information and methods to manipulate contents of GIF file. Below is a class diagram of gif.content:

+-------------+                         +-----------------------------+
| gif.content |images                   |            image            |
|-------------*-------------------------+-----------------------------|
|             |                     1.. +-----------------------------+
|             |
|             |                         +-----------------------------+
|             |Header                   |         gif.Header          |
|             *-------------------------+-----------------------------|
|             |                         +-----------------------------+
|             |
|             |                         +-----------------------------+
|             |LogicalScreenDescriptor  | gif.LogicalScreenDescriptor |
|             *-------------------------+-----------------------------|
|             |                         +-----------------------------+
|             |
|             |                         +-----------------------------+
|             |CommentExtension         |    gif.CommentExtension     |
|             *-------------------------+-----------------------------|
|             |                         +-----------------------------+
|             |
|             |                         +-----------------------------+
|             |PlainTextExntension      |   gif.PlainTextExtension    |
|             *-------------------------+-----------------------------|
|             |                         +-----------------------------+
|             |
|             |                         +-----------------------------+
|             |ApplicationExntension    | gif.ApplicationExtension    |
|             *-------------------------+-----------------------------|
|             |                         +-----------------------------+
+-------------+

21.2.1Constructor

gif.content
gif.content(stream?:stream:r, format:symbol => `rgba) {block?}
Reads a GIF data from a stream and returns an object that contains GIF related information and images of a specified format. format is is rgb,rgba or noimage. Ifnoimage is specified, only the information data is read

21.2.2Property

A gif.content instance has the following properties:

Property Type R/W Explanation
images image[] R
Header gif.Header R
LogicalScreenDescriptor gif.LogicalScreenDescriptor R
CommentExtension gif.CommentExtension R
PlainTextExtension gif.PlainTextExtension R
ApplicationExtension gif.ApplicationExtension R

21.2.3Method

gif.content#addimage
gif.content#addimage(image:image, delayTime:number => 10, leftPos:number => 0, topPos:number => 0, disposalMethod:symbol => `none):map:reduce
Adds an image to GIF information.

You can add multiple images that can be played as a motion picture.

The argument delayTime specifies the delay time in 10 milli seconds between images.

The arguments leftPost and topPos specifies the rendered offset in the screen.

The argument disposalMethod takes one of following symbols that specifies how the image will be treated after being rendered.

This method returns the reference to the target instance itself.

gif.content#write
gif.content#write(stream:stream:w):reduce
Writes a GIF image to a stream.

This method returns the reference to the target instance itself.

21.3gif.Header Class

A gif.Header instance provides information of Header structure in GIF format.

21.3.1Property

A gif.Header instance has the following properties:

Property Type R/W Explanation
Signature binary R
Version binary R

21.4gif.LogicalScreenDescriptor Class

A gif.LogicalScreenDescriptor instance provides information of Logical Screen Descriptor structure in GIF format.

21.4.1Property

A gif.LogicalScreenDescriptor instance has the following properties:

Property Type R/W Explanation
LogicalScreenWidth number R
LogicalScreenHeight number R
GlobalColorTableFlag boolean R
ColorResolution number R
SortFlag boolean R
SizeOfGlobalColorTable number R
BackgroundColorIndex number R
BackgroundColor color R
PixelAspectRatio number R

21.5gif.CommentExtension Class

A gif.CommentExtnsion instance provides information of Comment Extension structure in GIF format.

21.5.1Property

A gif.CommentExtension instance has the following properties:

Property Type R/W Explanation
CommentData binary R

21.6gif.PlainTextExtension Class

A gif.PlainTextExtnsion instance provides information of Plain Text Extension structure in GIF format.

21.6.1Property

A gif.PlainTextExtension instance has the following properties:

Property Type R/W Explanation
TextGridLeftPosition number R
TextGridTopPosition number R
TextGridWidth number R
TextGridHeight number R
CharacterCellWidth number R
CharacterCellHeight number R
TextForegroundColorIndex number R
TextBackgroundColorIndex number R
PlainTextData binary R

21.7gif.ApplicationExtension Class

A gif.ApplicationExtnsion instance provides information of Application Extension structure in GIF format.

21.7.1Property

A gif.ApplicationExtension instance has the following properties:

Property Type R/W Explanation
ApplicationIdentifier binary R
AuthenticationCode binary R
ApplicationData binary R

21.8gif.GraphicControl Class

A gif.GraphicControl instance provides information of Graphi Control Extension structure in GIF format.

21.8.1Property

A gif.GraphicControl instance has the following properties:

Property Type R/W Explanation
DisposalMethod symbol R
UserInputFlag boolean R
TransparentColorFlag boolean R
DelayTime number R
TransparentColorIndex number R

21.9gif.ImageDescriptor Class

A gif.ImageDescriptor instance provides information of Image Descriptor structure in GIF format.

21.9.1Property

A gif.ImageDescriptor instance has the following properties:

Property Type R/W Explanation
ImageLeftPosition number R
ImageTopPosition number R
ImageWidth number R
ImageHeight number R
LocalColorTableFlag boolean R
InterlaceFlag boolean R
SortFlag boolean R
SizeOfLocalColorTable number R

21.10gif.imgprop Class

Below is a class diagram of gif.imgprop:

+-------------+        +-------------+                  +---------------------+
|    image    |gif     | gif.imgprop |GraphicControl    | gif.GraphicControl  |
|-------------*--------+-------------*------------------+---------------------|
+-------------+        |             |                  +---------------------+
                       |             |
                       |             |                  +---------------------+
                       |             |ImageDescriptor   | gif.ImageDescriptor |
                       |             *------------------+---------------------|
                       |             |                  +---------------------+
                       +-------------+

21.10.1Property

A gif.imgprop instance has the following properties:

Property Type R/W Explanation
GraphicControl gif.GraphicControl R
ImageDescriptor gif.ImageDescriptor R

21.11Extension to image Class

This module extends the stream class with methods described here.

image#read@gif
image#read@gif(stream:stream:r):reduce
Reads a GIF image from a stream.

This method returns the reference to the target instance itself.

image#write@gif
image#write@gif(stream:stream:w):reduce
Writes a GIF image to a stream.

This method returns the reference to the target instance itself.

Property Type R/W Explanation
gif gif.imgprop R


Copyright (C) 2011-2017 ypsitau