A plug-in is a (more or less) little program that enhances the functionality of The GIMP.
There are two different types of plug-ins:
provide reading and writing of various graphic-file-formats.
calculate effects and filters to an image.
Everytime you invoke a plug-in from the menu The GIMP executes the following steps:
fork ()
.As soon as the plug-in calls gimp_init ()
(see section
sec.init)
the plug-in sets its pipe-file-descriptors to the given arguments and is ready
for communication.
Needs work...
The GIMP provides three types of images: true color, grayscale and 8-bit indexed color images. An alpha-channel can be added to each of that three types so that we have six types altogether. The differences between these six types are shown in table Differences between image types.
Table tab.imagetypes: Differences between image types
image type identifier bytes per pixel color depth
--------------------- ------------- --------------- -----------
true color RGB_IMAGE 3 16.777.216
true color with alpha RGBA_IMAGE 4 16.777.216
grayscale GRAY_IMAGE 1 256
grayscale with alpha GRAYA_IMAGE 2 256
indexed INDEXED_IMAGE 1 256
indexed with alpha INDEXEDA_IMAGE 2 256
For it has become senseless to use indexed color images today, you will work with true color or grayscaled images almost. The main reason for programmers not to support indexed color images in their plug-ins is the impossibility of interpolating pixel-values in a color map.
Each pixel of a true color image consists of a RGB-triplet (see table tab.internal-rgb). A RGB-triplet needs three bytes in memory, because each red, green and blue part of a color can take values between 0 and 255. These parts are known to The GIMP as color channels also.
With three color channels you can compose up to 256 * 256 * 256 = 256ˆ3 = 16.777.216 different colors - more than enough for smooth coloring.
In contrast to true color images a pixel of a grayscale image needs one byte in memory only. That is, because you have 256 different values for brightness: 0 represents black, 255 represents white. See table tab.internal-gray-indexed.
The indexed color image can be called an awkwark image type for filter programming. As you see in table Color map of an indexed color image any of the 256 available colors is defined in a color map.
Table tab.indexed-color-table: Color map of an indexed color image
col. RGB-triplets
---- --------------
0 r000 g000 b000
1 r001 g001 b001
2 r002 g002 b002
... ...
254 r254 g254 b254
255 r255 g255 b255
It is not difficult to program something like brightness or gamma correction with a color map, but as soon as you need color interpolation to create smooth colors you obviously have no chance to do it in a nice way. One solution could be to convert the indexed image into a true color image, then calculate the filter and convert it back into an indexed image. But I think that doesn't look perfect.
Another disadvantage of indexed images is that although each red, green and blue value of the color map needs one byte, you actually have six bits per value. Sometimes you can set values 0...63, sometimes 0...255. It depends on the application to right-shift the full byte range by two bits to get back to six bits.
With three times six bits you can compose up to 64 * 64 * 64 = 64ˆ3 = 262.144 different colors but you can only use 256 colors simultaneous.
The internal representation of the image data is shown in tables tab.internal-rgb and tab.internal-gray-indexed. The first pixel in memory is the upper-left corner of the image, the last one is the lower-right corner (remember, that every pixel needs as many bytes in memory as there are color channels in the image).
See section sec.filter-function for an example how to walk through the image data and handle the correct positions.
Table tab.internal-rgb: Internal representation of true color images.
r g b r g b ... r g b
RGB_1 RGB_2 ... RGB_x
r g b r g b ... r g b
RGB_x+1 RGB_x+2 ... RGB_2x
... ... ... ...
r g b r g b ... r g b
RGB_(y-1)x+1 RGB_(y-1)x+2 ... RGB_yx
Table tab.internal-gray-indexed: Internal representation of grayscale and indexed color images.
v_1 v_2 ... v_x
v_x+1 v_x+2 ... v_2x
... ... ... ...
v_(y-1)x+1 v_(y-1)x+2 ... v_yx
.gimprc
FileThe .gimprc
file should be placed in your home directory
( ~
.gimprc/). It contains the following fields:
Defines the directory where swap files will appear.
Defines the directories where The GIMP searches valid brushes at startup.
Sets the default brush.
The brush file has to be placed in any of the paths given in brush-path
.
Defines the directories where The GIMP searches for plug-ins when the plug-in is run.
Defines available file plug-ins. plug-in-name is the name of the executable file plug-in. image-types consists of three digits where each digit is 0 or 1. It defines what image types the plug-in can save. The digits correspond to indexed, grayscale and rgb. plug-in-title is the name of the plug-in for The GIMP. This will most likely be the name of the plug-in. extensions defines the possible file extensions for the plug-in.
Examples: The jpeg
filter can save grayscaled and true color
images but no indexed images, the gif
filter can save indexed
and grayscaled images but no true color images. So you would define
in .gimprc
:
file-plug-in jpeg 011 "jpeg" "jpg,jpeg"
file-plug-in gif 110 "gif" "gif"
Note: In the original .gimprc
-comments that come with
The GIMP v0.54 the format of the line file-plug-in
is defined as
file-plug-in
image-types plug-in-name plug-in-title extension
which obviously is wrong.
Defines available plug-ins. plug-in-name is the name of the executable plug-in. menu-location defines the appearance of the plug-in in the submenu Filters, e.g. if you define a menu-location
"Effects/Invert"then
Effects
becomes a submenu of Filters. Invert
is the menu item
that starts the plug-in. Menus and submenus are sorted in alphabetical
order. accelerator-key defines the keys that start the plug-in. That
string has the format
"[Shift] [Alt] <Key> Letter"
accelerator-text appears in the menu entry of the plug-in.
Examples:
plug-in bleed "FX/Bleed"
plug-in edge "FX/Edge Detect" "Alt<Key>E" "Alt+E"
plug-in gauss "Blur/Gaussian" "Shift Alt<Key>B" "Shft+Alt+B"
Note that paths are separated by ``:
''.