3 # Overall demo of the major PerlMagick methods.
8 # Read model & smile image.
11 $null=Image::Magick->new;
12 $null->Set(size=>'70x70');
13 $x=$null->ReadImage('NULL:black');
16 $model=Image::Magick->new();
17 $x=$model->ReadImage('model.gif');
19 $model->Label('Magick');
20 $model->Set(background=>'white');
22 $smile=Image::Magick->new;
23 $x=$smile->ReadImage('smile.gif');
25 $smile->Label('Smile');
26 $smile->Set(background=>'white');
30 print "Transform image...\n";
31 $images=Image::Magick->new();
33 print "Adaptive Blur...\n";
34 $example=$model->Clone();
35 $example->Label('Adaptive Blur');
36 $example->AdaptiveBlur('0x1');
37 push(@$images,$example);
39 print "Adaptive Resize...\n";
40 $example=$model->Clone();
41 $example->Label('Adaptive Resize');
42 $example->AdaptiveResize('60%');
43 push(@$images,$example);
45 print "Adaptive Sharpen...\n";
46 $example=$model->Clone();
47 $example->Label('Adaptive Sharpen');
48 $example->AdaptiveSharpen('0x1');
49 push(@$images,$example);
51 print "Adaptive Threshold...\n";
52 $example=$model->Clone();
53 $example->Label('Adaptive Threshold');
54 $example->AdaptiveThreshold('5x5+5%');
55 push(@$images,$example);
57 print "Add Noise...\n";
58 $example=$model->Clone();
59 $example->Label('Add Noise');
60 $example->AddNoise("Laplacian");
61 push(@$images,$example);
63 print "Annotate...\n";
64 $example=$model->Clone();
65 $example->Label('Annotate');
66 $example->Annotate(text=>'Magick',geometry=>'+0+20',font=>'Generic.ttf',
67 fill=>'gold',gravity=>'North',pointsize=>14);
68 push(@$images,$example);
70 print "Auto-gamma...\n";
71 $example=$model->Clone();
72 $example->Label('Auto Gamma');
73 $example->AutoGamma();
74 push(@$images,$example);
76 print "Auto-level...\n";
77 $example=$model->Clone();
78 $example->Label('Auto Level');
79 $example->AutoLevel();
80 push(@$images,$example);
83 $example=$model->Clone();
84 $example->Label('Blur');
85 $example->Blur('0.0x1.0');
86 push(@$images,$example);
89 $example=$model->Clone();
90 $example->Label('Border');
91 $example->Border(geometry=>'6x6',color=>'gold');
92 push(@$images,$example);
95 $example=$model->Clone();
96 $example->Label('Channel');
97 $example->Channel(channel=>'red');
98 push(@$images,$example);
100 print "Charcoal...\n";
101 $example=$model->Clone();
102 $example->Label('Charcoal');
103 $example->Charcoal('2x1');
104 push(@$images,$example);
106 print "ColorMatrix...\n";
107 $example=$model->Clone();
108 $example->Label('ColorMatrix');
109 $example->ColorMatrix([1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0.5, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
110 push(@$images,$example);
112 print "Composite...\n";
113 $example=$model->Clone();
114 $example->Label('Composite');
115 $example->Composite(image=>$smile,compose=>'over',geometry=>'+35+65');
116 push(@$images,$example);
118 print "Contrast...\n";
119 $example=$model->Clone();
120 $example->Label('Contrast');
121 $example->Contrast();
122 push(@$images,$example);
124 print "Contrast Stretch...\n";
125 $example=$model->Clone();
126 $example->Label('Contrast Stretch');
127 $example->ContrastStretch('5%');
128 push(@$images,$example);
130 print "Convolve...\n";
131 $example=$model->Clone();
132 $example->Label('Convolve');
133 $example->Convolve([0.125, 0.125, 0.125, 0.125, 0.5, 0.125, 0.125, 0.125, 0.125]);
134 push(@$images,$example);
137 $example=$model->Clone();
138 $example->Label('Crop');
139 $example->Crop(geometry=>'80x80+25+50');
140 $example->Set(page=>'0x0+0+0');
141 push(@$images,$example);
143 print "Despeckle...\n";
144 $example=$model->Clone();
145 $example->Label('Despeckle');
146 $example->Despeckle();
147 push(@$images,$example);
149 print "Distort...\n";
150 $example=$model->Clone();
151 $example->Label('Distort');
152 $example->Distort(method=>'arc',points=>[60],'virtual-pixel'=>'white');
153 push(@$images,$example);
156 $example=$model->Clone();
157 $example->Label('Draw');
158 $example->Draw(fill=>'none',stroke=>'gold',primitive=>'circle',
159 points=>'60,90 60,120',strokewidth=>2);
160 push(@$images,$example);
162 print "Detect Edges...\n";
163 $example=$model->Clone();
164 $example->Label('Detect Edges');
165 $example->Edge('2x0.5');
166 push(@$images,$example);
169 $example=$model->Clone();
170 $example->Label('Emboss');
171 $example->Emboss('0x1');
172 push(@$images,$example);
174 print "Equalize...\n";
175 $example=$model->Clone();
176 $example->Label('Equalize');
177 $example->Equalize();
178 push(@$images,$example);
180 print "Implode...\n";
181 $example=$model->Clone();
182 $example->Label('Explode');
183 $example->Implode(-1);
184 push(@$images,$example);
187 $example=$model->Clone();
188 $example->Label('Flip');
190 push(@$images,$example);
193 $example=$model->Clone();
194 $example->Label('Flop');
196 push(@$images,$example);
199 $example=$model->Clone();
200 $example->Label('Frame');
201 $example->Frame('15x15+3+3');
202 push(@$images,$example);
205 $example=$model->Clone();
206 $example->Label('Fx');
207 push(@$images,$example->Fx(expression=>'0.5*u'));
210 $example=$model->Clone();
211 $example->Label('Gamma');
212 $example->Gamma(1.6);
213 push(@$images,$example);
215 print "Gaussian Blur...\n";
216 $example=$model->Clone();
217 $example->Label('Gaussian Blur');
218 $example->GaussianBlur('0.0x1.5');
219 push(@$images,$example);
221 print "Gradient...\n";
222 $gradient=Image::Magick->new;
223 $gradient->Set(size=>'130x194');
224 $x=$gradient->ReadImage('gradient:#20a0ff-#ffff00');
226 $gradient->Label('Gradient');
227 push(@$images,$gradient);
229 print "Grayscale...\n";
230 $example=$model->Clone();
231 $example->Label('Grayscale');
232 $example->Set(type=>'grayscale');
233 push(@$images,$example);
235 print "Implode...\n";
236 $example=$model->Clone();
237 $example->Label('Implode');
238 $example->Implode(0.5);
239 push(@$images,$example);
242 $example=$model->Clone();
243 $example->Label('Level');
244 $example->Level('20%');
245 push(@$images,$example);
247 print "Median Filter...\n";
248 $example=$model->Clone();
249 $example->Label('Median Filter');
250 $example->MedianFilter('4x4');
251 push(@$images,$example);
254 $example=$model->Clone();
255 $example->Label('Mode');
256 $example->Mode('4x4');
257 push(@$images,$example);
259 print "Modulate...\n";
260 $example=$model->Clone();
261 $example->Label('Modulate');
262 $example->Modulate(brightness=>110,saturation=>110,hue=>110);
263 push(@$images,$example);
264 $example=$model->Clone();
266 print "Monochrome...\n";
267 $example=$model->Clone();
268 $example->Label('Monochrome');
269 $example->Quantize(colorspace=>'gray',colors=>2,dither=>'false');
270 push(@$images,$example);
272 print "Morphology...\n";
273 $example=$model->Clone();
274 $example->Label('Morphology');
275 $example->Morphology(method=>'Dilate',kernel=>'Diamond',iterations=>2);
276 push(@$images,$example);
278 print "Motion Blur...\n";
279 $example=$model->Clone();
280 $example->Label('Motion Blur');
281 $example->MotionBlur('0x13+10-10');
282 push(@$images,$example);
285 $example=$model->Clone();
286 $example->Label('Negate');
288 push(@$images,$example);
290 print "Normalize...\n";
291 $example=$model->Clone();
292 $example->Label('Normalize');
293 $example->Normalize();
294 push(@$images,$example);
296 print "Oil Paint...\n";
297 $example=$model->Clone();
298 $example->Label('Oil Paint');
299 $example->OilPaint('2x0.5');
300 push(@$images,$example);
303 $plasma=Image::Magick->new;
304 $plasma->Set(size=>'130x194');
305 $x=$plasma->ReadImage('plasma:fractal');
307 $plasma->Label('Plasma');
308 push(@$images,$plasma);
310 print "Polaroid...\n";
311 $example=$model->Clone();
312 $example->Label('Polaroid');
313 $example->Polaroid(caption=>'Magick',angle=>-5.0,gravity=>'center');
314 push(@$images,$example);
316 print "Posterize...\n";
317 $example=$model->Clone();
318 $example->Label('Posterize');
319 $example->Posterize(5);
320 push(@$images,$example);
322 print "Quantize...\n";
323 $example=$model->Clone();
324 $example->Label('Quantize');
325 $example->Quantize();
326 push(@$images,$example);
328 print "Radial Blur...\n";
329 $example=$model->Clone();
330 $example->Label('Radial Blur');
331 $example->RadialBlur(10);
332 push(@$images,$example);
335 $example=$model->Clone();
336 $example->Label('Raise');
337 $example->Raise('10x10');
338 push(@$images,$example);
340 print "Reduce Noise...\n";
341 $example=$model->Clone();
342 $example->Label('Reduce Noise');
343 $example->ReduceNoise('2x2');
344 push(@$images,$example);
347 $example=$model->Clone();
348 $example->Label('Resize');
349 $example->Resize('60%');
350 push(@$images,$example);
353 $example=$model->Clone();
354 $example->Label('Roll');
355 $example->Roll(geometry=>'+20+10');
356 push(@$images,$example);
359 $example=$model->Clone();
360 $example->Label('Rotate');
361 $example->Rotate(45);
362 push(@$images,$example);
365 $example=$model->Clone();
366 $example->Label('Sample');
367 $example->Sample('60%');
368 push(@$images,$example);
371 $example=$model->Clone();
372 $example->Label('Scale');
373 $example->Scale('60%');
374 push(@$images,$example);
376 print "Segment...\n";
377 $example=$model->Clone();
378 $example->Label('Segment');
380 push(@$images,$example);
383 $example=$model->Clone();
384 $example->Label('Shade');
385 $example->Shade(geometry=>'30x30',gray=>'true');
386 push(@$images,$example);
388 print "Sharpen...\n";
389 $example=$model->Clone();
390 $example->Label('Sharpen');
391 $example->Sharpen('0.0x1.0');
392 push(@$images,$example);
395 $example=$model->Clone();
396 $example->Label('Shave');
397 $example->Shave('10x10');
398 push(@$images,$example);
401 $example=$model->Clone();
402 $example->Label('Shear');
403 $example->Shear('-20x20');
404 push(@$images,$example);
407 $example=$model->Clone();
408 $example->Label('Sketch');
409 $example->Set(colorspace=>'Gray');
410 $example->Sketch('0x20+120');
411 push(@$images,$example);
413 print "Sigmoidal Contrast...\n";
414 $example=$model->Clone();
415 $example->Label('Sigmoidal Contrast');
416 $example->SigmoidalContrast("3x50%");
417 push(@$images,$example);
420 $example=$model->Clone();
421 $example->Label('Spread');
423 push(@$images,$example);
425 print "Solarize...\n";
426 $example=$model->Clone();
427 $example->Label('Solarize');
428 $example->Solarize();
429 push(@$images,$example);
432 $example=$model->Clone();
433 $example->Label('Swirl');
435 push(@$images,$example);
438 $example=$model->Clone();
439 $example->Label('Tint');
440 $example->Tint('wheat');
441 push(@$images,$example);
443 print "Unsharp Mask...\n";
444 $example=$model->Clone();
445 $example->Label('Unsharp Mask');
446 $example->UnsharpMask('0.0x1.0');
447 push(@$images,$example);
449 print "Vignette...\n";
450 $example=$model->Clone();
451 $example->Label('Vignette');
452 $example->Vignette('0x20');
453 push(@$images,$example);
456 $example=$model->Clone();
457 $example->Label('Wave');
458 $example->Wave('25x150');
459 push(@$images,$example);
461 # Create image montage.
463 print "Montage...\n";
464 $montage=$images->Montage(geometry=>'128x160+8+4>',gravity=>'Center',
465 tile=>'5x+10+200',compose=>'over',background=>'#ffffff',
466 font=>'Generic.ttf',pointsize=>18,fill=>'#600',stroke=>'none',
469 $logo=Image::Magick->new();
470 $logo->Read('logo:');
472 $montage->Composite(image=>$logo,gravity=>'North');
475 $montage->Set(matte=>'false');
476 $montage->Write('demo.jpg');
477 print "Display...\n";
478 $montage->Write('win:');