> if I have an image and I want to use the colors of that image, how do i
> make a custom gradient?
First method (long and tedious):
Use the gradient editor, picking colors from the image and
dropping them into the gradient as described in the
GimpUsersManual_2ndEdition.pdf.
An easier method:
I have wondered about this myself in connection with palettes,
which often have a nicely selected set of colors already
available. I have built a pair of little perl procs to (1) sort
a palette by value, hue, saturation, or hsv_value,
and (2) create a gradient from a palette. In the hope that
these may answer your need, I have attached them.
Caveats: They are NOT documented very well. Consider them
beta, at best. I have used them successfully myself, but YMMV.
Particularly on pal2grad.pl, read the code. You can set the number of steps in the resulting gradient.
--
--Jeff
Jeff Trefftzs <[EMAIL PROTECTED]>
http://www.tcsn.net/trefftzs Home Page
http://gug.sunsite.dk/gallery.php&artist=68 Gimp Gallery
http://members4.clubphoto.com/jeff309574 A photo gallery
http://www.photos4all.net/jefftzs Another photo gallery
#!/usr/local/bin/perl # pal2grad.pl - convert a GIMP palette to a gradient. use strict; use vars qw($opt_r $opt_b $opt_n); use Getopt::Std; # parse command line arguments getopts('rbn:'); if ($ARGV < 0) { die "$ARGV[0]: Can't find a file to process\n"; } my @PALETTE = (); my @GRADIENT = (); while (<>) { if(/^[^0-9 ]/) { # skip comments and headers next; } push @PALETTE, $_; } my $STEPS = $#PALETTE; # how many entries in the palette my $count = (defined $opt_n) ? $opt_n : $STEPS; my $width = 1.0/$count; # width of one segment my $demi = $width/2; # distance to midpoint my @oldcolor = split(/\s/, $PALETTE[0], 3); my $alpha = 1.0; for (my $i = 1; $i <= $count; $i++) { my $index = $i * ($STEPS/$count); my ($red, $green, $blue) = split(/\s/, $PALETTE[$index], 3); # printf stderr "red=$red, green=$green, blue=$blue\n"; my ($start, $middle, $end) = (($i -1) * $width, $i * $width - $demi, $i * $width); if (defined $opt_r) { $start = 1.0 - $end; $middle = 1.0 - $middle; $end = 1.0 - (($i - 1) * $width); } my $grad_entry = sprintf ("%f %f %f %f %f %f %f %f %f %f %f %d %d\n", $start, $middle, $end, $oldcolor[0]/255, # starting red $oldcolor[1]/255, # starting green $oldcolor[2]/255, # starting blue $alpha, $red/255, # ending red $green/255, # ending green $blue/255, # ending blue $alpha, # Opacity - constant for now 0, # linear blend 0 # rgb coloring ); if (!(defined $opt_r)) { push @GRADIENT, $grad_entry; } else { unshift @GRADIENT, $grad_entry; } @oldcolor = ($red, $green, $blue); } print "GIMP Gradient\n"; printf "%d\n", $count; print @GRADIENT;