Passed
Branch master (b68248)
by compolom
03:29 queued 01:22
created

out_base64()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 5
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Compolomus\Compomage\Image;
4
5
require '../../vendor/autoload.php';
6
7
/**
8
 * @param string $image
9
 * @param int $width
10
 * @param int $height
11
 * @param int $startX
12
 * @param int $startY
13
 * @return string
14
 * @throws Exception
15
 */
16
function out_base64(string $image, int $width, int $height, int $startX, int $startY): string
17
{
18
    $obj = new Image($image, Image::GD); // Image::IMAGICK
19
    return '<img src="data:image/png;base64,' . $obj->crop( $width, $height, $startX, $startY)->getBase64() . '" alt="base64_image" />'
20
        . '<div>input w h x y = ' . implode(' | ',  [$width, $height, $startX, $startY]) . '</div>';
21
}
22
23
echo out_base64($_REQUEST['image'], $_REQUEST['width'], $_REQUEST['height'], $_REQUEST['x'], $_REQUEST['y']);
24