1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use 5.010; use Image::Magick; # Bild $pic1 = Image::Magick->new(); $result = $pic1->ReadImage('pic1.gif'); warn "$result" if "$result"; # Wasserzeichen/Logo $pic2 = Image::Magick->new; $result = $pic2->ReadImage('pic2.gif'); warn "$result" if "$result"; # Bild zusammensetzen $endpic = $pic1->Clone(); # pic2 in Größe 50x50 bei Position 35x65 einpassen # zu offsets siehe <http://www.imagemagick.org/script/command-line-processing.php#geometry> $endpic->Composite( image => $pic2, compose => 'add', geometry => '50x65+35+65' ); # Bild speichern $endpic->Write('ergebnis.jpg');
QuoteWo hats denn bei dir gehakt? Was hast du probiert? Wäre interessant zu wissen für andere, welche Fallen es gibt.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## Wasserzeichen/Logo $pic2 = Image::Magick->new; $result = $pic2->ReadImage('wz.png'); warn "$result" if "$result"; $result = $pic2->Resize(width => 100, height => 50); # auf andere Größe warn "$result" if "$result"; $result = $pic2->Crop(width => 30, height => 10); # Zuschneiden warn "$result" if "$result"; # Bild zusammensetzen $endpic = $pic1->Clone(); # zu offsets siehe <http://www.imagemagick.org/script/command-line-processing.php#geometry> $result = $endpic->Composite( image => $pic2, compose => 'over', geometry => '+600+200', # an Pos 600/200 einfügen ); warn "$result" if "$result";
$img->Annotate(
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
print "... create new final-image\n";
my $img_final = Image::Magick->new();
print "... read basic map\n";
my $result_read_basic = $img_final->Read($map_basic);
warn "$result_read_basic" if "$result_read_basic";
# Bildgröße setzen
#my $image_width_dpi = int($area2plot[0]*$dpi/25.4);
#my $image_height_dpi = int($area2plot[1]*$dpi/25.4);
#$img_final->Set(size=>$image_width_dpi.'x'.$image_height_dpi, fill => 'white');
#$img_final->ReadImage('xc:White');
if (!-e $map_ovl1){
print "*** overlay1 not found ! (name:= ".$map_ovl1.")\n";
} else {
print "... create new overlay1-image\n";
my $img_ovl1 = Image::Magick->new();
print "... read overlay1 map\n";
my $warn_read_ovl1 = $img_ovl1->Read($map_ovl1);
warn "$warn_read_ovl1" if "$warn_read_ovl1";
# einbinden des Overlay
print "... sandwich overlay1\n";
$img_final->Composite(
image => $img_ovl1,
compose => 'add',
geometry => $image_width_dpi.'x'.$image_height_dpi.'+0+0'
);
}
print "... write final-map (name:= ".$map_final.")\n";
my $result_write_ovl1 = $img_final->Write($map_final);
warn "$result_write_ovl1" if "$result_write_ovl1";
print "--> complete\n";
} # end-while
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#!/usr/bin/perl use 5.008; use strict; use warnings; use Image::Magick; my $w; my $karte = Image::Magick->new(); $w = $karte->ReadImage('karte.png'); die $w if $w; my $overlay = Image::Magick->new(); $w = $overlay->Set( size => '800x600' ); die $w if $w; $w = $overlay->ReadImage('xc:none'); die $w if $w; my $globe = Image::Magick->new(); $w = $globe->ReadImage('globe.png'); die $w if $w; $w = $overlay->Composite( geometry => '10x10', image => $globe, compose => 'over' ); die $w if $w; $w = $overlay->Annotate( text => 'Karte 1', font => 'arialb.ttf', fill => 'blue', pointsize => '36', geometry => '+400+50' ); die $w if $w; my $arrow = Image::Magick->new(); $w = $arrow->ReadImage('arrow.png'); die $w if $w; $w = $overlay->Composite( geometry => '+700+10', image => $arrow, compose => 'over' ); die $w if $w; $w = $overlay->Annotate( text => '(c)2134 Copyleft by Prof.Gwen.Dr.Agon', font => 'ariali.ttf', fill => 'black', pointsize => '24', geometry => '+10+600' ); die $w if $w; $w = $karte->Composite( geometry => '+10+10', image => $overlay, compose => 'over' ); die $w if $w; $w = $karte->Write('demo.jpg'); die $w if $w;
Quotemanchen Ecken schwer oder gar nicht nach zu vollziehen, so gehts mir jedenfalls.