-
Notifications
You must be signed in to change notification settings - Fork 27
/
php-imagick.inc
55 lines (42 loc) · 1.18 KB
/
php-imagick.inc
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
<?php
/**
* Tests for Imagick
*/
function test_35_imagick_qrcode()
{
global $testsLoopLimits, $totalOps, $qr;
$size = 25; // Dimension in dots
$dot = 9; // Pixels per dot
$imgW = $imgH = $size;
$count = $testsLoopLimits['35_imagick_qrcode'];
$time_start = get_microtime();
$pixelPerPoint = 9;
$outerFrame = 1;
$q = 75;
$col[0] = new ImagickPixel("white");
$col[1] = new ImagickPixel("black");
for ($c=0; $c<$count; $c++) {
$image = new Imagick();
$image->newImage($imgW, $imgH, $col[0]);
$image->setCompressionQuality($q);
$image->setImageFormat('jpeg');
$draw = new ImagickDraw();
$draw->setFillColor($col[1]);
// Loop over all dots and draw them:
for ($y = 0, $i = 0; $y < $size; $y++) {
for ($x = 0; $x < $size; $x++, $i++) {
if ($qr[$i] == '1') { // Draw a dot?
$draw->point($x,$y);
}
}
}
$image->drawImage($draw);
$image->borderImage($col[0],$outerFrame,$outerFrame);
$image->scaleImage( $imgW * $pixelPerPoint, 0 );
// Save the result
// $image->writeImages("test-im.jpg",true);
$image->writeImages("/dev/null",true);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}