-
Notifications
You must be signed in to change notification settings - Fork 2
/
appendImages2.php
32 lines (27 loc) · 1000 Bytes
/
appendImages2.php
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
<?php
$images = [["img/annotateImage.png",
"img/addNoiseImage.png"],
["img/adaptiveThresholdImage.png",
"img/adaptiveblur.png"]];
$canvas = new Imagick();
foreach ($images as $imageRow) {
$rowImagick = new Imagick();
$rowImagick->setBackgroundColor('gray');
foreach ($imageRow as $imagePath) {
$imagick = new Imagick(realpath($imagePath));
$imagick->setImageBackgroundColor("gray");
$imagick->resizeimage(200, 200, \Imagick::FILTER_LANCZOS, 1.0, true);
$rowImagick->addImage($imagick);
}
$rowImagick->resetIterator();
//Add the images horizontally.
$combinedRow = $rowImagick->appendImages(false);
$canvas->addImage($combinedRow);
}
$canvas->resetIterator();
//Add the images vertically.
$finalimage = $canvas->appendImages(true);
$finalimage->setImageFormat('png');
header("Content-Type: image/png");
echo $finalimage;
?>