O'Reilly logo

Programming Web Graphics with Perl and GNU Softwar by Shawn Wallace

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Color Control, Palettes, and Patterns

A color is represented by an anonymous array of three elements representing the red, green, and blue values:

my $red = [ 255, 0, 0 ];

The Gimp comes with several default patterns, palettes, and gradients, all of which may be referred to by name:

# Set the current pattern
my $pattern = "Blob1";
gimp_patterns_set_pattern($pattern);

# Convert $image to an indexed palette
my $palette = "Reds_And_Purples";
gimp_convert_indexed_palette($image, 1, 4, 0, $palette);

# Set the active gradient
my $gradient = "Mexican_flag_smooth";
gimp_gradients_set_active($gradient);

Table C-4. Procedures for Manipulating the Colors in an Image, and Managing Palettes and Patterns

Name

Description

Arguments

gimp_brightness_contrast

Modify brightness/contrast in the specified drawable

image (Image)

The image

drawable (Drawable)

The drawable

brightness (Integer)

Brightness adjustment in the range -127 to 127

contrast (Integer)

Constrast adjustment in the range -127 to 127

gimp_color_balance

Modify the color balance of the specified drawable

image (Image)

The image

drawable (Drawable)

The drawable

transfer_mode (Integer)

Transfer mode

0

Shadows

1

Midtones

2

Highlights

preserve_lum (Integer)

Preserve luminosity values at each pixel

cyan_red (Float)

Cyan-Red color balance in the range -100 to 100

magenta_green (Float)

Magenta-Green color balance in the range -100 to 100

yellow_blue (Float)

Yellow-Blue color balance in the range -100 to 100

gimp_color_picker

Determine the color at the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required