out_base64()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

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