blob: 5e80bd0af4a7c90a0eaabbf1db0c6725c5849d23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<?php
$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true);
$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ?? "/assets/uploads/raindrops.png") : "/assets/uploads/raindrops.png";
file_put_contents("/tmp/temp", file_get_contents($url));
header("Content-Type: image/png");
$id = bin2hex(random_bytes(8));
exec('convert -size 128x128 xc:none -draw "roundrectangle 0,0,128,128,128,128" /tmp/' . $id . '-mask.png', $out);
exec('convert -resize 128x128 "/tmp/temp" /tmp/' . $id . '-source.png');
exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask.png -compose DstIn -composite /tmp/' . $id . '.png', $out2);
unlink("/tmp/temp");
echo(file_get_contents('/tmp/' . $id . '.png'));
|