Gimp

 view release on metacpan or  search on metacpan

examples/bricks  view on Meta::CPAN

  # make a copy of it for bump mapping
  $image->selection_all;
  $layer->edit_copy();
  my $border = $image->add_new_layer(0,0,0);
  #print "$border\n";
  $border->edit_paste(0)->floating_sel_anchor;
  $image->selection_none;
  $border->gauss_iir (2,1,1);
  $layer->gauss_iir (2,1,1);
  $layerpat->bump_map($layer,280,40,2,0,0,0,0,1,0,1);
  # overlay border lines and random skew bricks
  $image->undo_group_start;
  $h = 0; $j = 0; $wo = 0;
  while ($h < $imageh) {
    $w = 0; $wo = 0; $wo = ($brickw / 2) if ($j == 1);
    while ($w < $imagew) {
      my $r = int(rand ($skew) - ($skew / 1));
      if ($r != 0) {
	Gimp::Context->set_foreground ("#ffffff") if ($r > 0);
	Gimp::Context->set_foreground ("#000000") if ($r < 0);
	$image->select_rectangle(2,$w+$wo,$h,$brickw,$brickh);

examples/frame_filter  view on Meta::CPAN

use warnings;

podregister {
  my @layers = $image->get_layers;
  my $n = @layers or die "At least one layer is required\n";
  my ($i, $I, $p, $P, $d); # declare here so seen by eval below
  my $func = eval "sub{\nno strict;\n#line 0 \"expression\"\n$expr\n}";
  die "Syntax error in expression '$expr': $@\n" if $@;
  # now apply the expr
  eval { $image->undo_group_start };
  # 5.004 has problems with overlaying functions
  Gimp->progress_init("Applying Expression...",-1);
  for $i (0..$n-1) {
    $I = $n-$i-1;
    $p = @layers > 1 ? $i/$#layers : 0;
    $P = 1-$p;
    $d = $layers[$i];
    eval { &$func };
    die "Evaluation error in frame $i: $@\n" if $@;
    Gimp->progress_update(($i+1)/$n);
  }

examples/image_tile  view on Meta::CPAN


      if (!defined($minmatch) || $match < $minmatch) {
	$minmatch = $match;
	$matchid = $subimg;
      }
    }
    if (!defined($matchid)) {
      die("image_tile: No subimages selected!");
    }
    # Actually insert the selected image.
    overlay_image($drawable, $matchid,
		  $xtilewidth*$x, $ytileheight*$y,
		  $xtilewidth, $ytileheight);
    $wt_cache{$matchid} += $dupweight;
  }
  # Finish up.
  undef $db;
  untie %tile_cache;
  undef $wdb;
  untie %wt_cache;
  unlink($wt_file);

examples/image_tile  view on Meta::CPAN

    my $oldwidth = $width;
    $width = int($target_aspect * $height);
    # print "Image was $oldwidth X $height, cropping to $width X $height\n";
    $img->crop($width, $height, int(($oldwidth-$width) / 2), 0);
  }
}

# Take DRAWABLE, INFO, X, Y, WIDTH, HEIGHT
# Opens image referenced by INFO->{name} and scale/crop to fit in rectagnle
# described by X,Y,WIDTH,HEIGHT
sub overlay_image {
  my ($draw, $file, $x, $y, $width, $height) = @_;
  my $img = Gimp->file_load($file, $file);
  my $subwidth = $img->width;
  my $subheight = $img->height;
  match_aspect($img, $width/$height, $subwidth, $subheight);
  $img->scale($width, $height);
  $img->get_active_drawable->edit_copy;
  my $baseimg = $draw->get_image;
  $baseimg->select_rectangle(CHANNEL_OP_REPLACE, $x, $y, $width, $height);
  $draw->edit_paste(FALSE)->floating_sel_anchor;



( run in 0.403 second using v1.01-cache-2.11-cpan-49f99fa48dc )