summaryrefslogtreecommitdiff
path: root/pages/api/raindrops-img2-round2.php
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-05-29 20:56:34 +0200
committerRaindropsSys <contact@minteck.org>2023-05-29 20:56:34 +0200
commit1c7477be214a95d7c551e627b11d1d63fe82a553 (patch)
treece8cc3e18ec49f7a7866409667b362812d51538b /pages/api/raindrops-img2-round2.php
parenta542c7beec172123100bca3c59a42109ee7e2d08 (diff)
downloadpluralconnect-1c7477be214a95d7c551e627b11d1d63fe82a553.tar.gz
pluralconnect-1c7477be214a95d7c551e627b11d1d63fe82a553.tar.bz2
pluralconnect-1c7477be214a95d7c551e627b11d1d63fe82a553.zip
Added 2 files (automated)
Diffstat (limited to 'pages/api/raindrops-img2-round2.php')
-rw-r--r--pages/api/raindrops-img2-round2.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/pages/api/raindrops-img2-round2.php b/pages/api/raindrops-img2-round2.php
new file mode 100644
index 0000000..5eb7e3f
--- /dev/null
+++ b/pages/api/raindrops-img2-round2.php
@@ -0,0 +1,20 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true);
+
+$url = isset($fronters['members'][1]) ? (getAsset("gdapd", $fronters["members"][1]["id"], "avatars") ?? "/assets/uploads/pt.png") : "/assets/uploads/pt.png";
+file_put_contents("/tmp/temp", file_get_contents($_SERVER['DOCUMENT_ROOT'] . $url));
+
+header("Content-Type: image/png");
+
+$id = bin2hex(random_bytes(8));
+exec('convert -size 256x128 xc:none -draw "roundrectangle 0,0,256,128,128,128" -chop 128x0 -resize 64x128\! /tmp/' . $id . '-mask.png', $out);
+exec('convert /tmp/' . $id . '-mask.png -gravity West -background black -splice 64x0 -distort SRT 90 /tmp/' . $id . '-mask2.png', $out);
+
+exec('convert -resize 128x128 -filter Point -background transparent -gravity center -extent 128x128 "/tmp/temp" /tmp/' . $id . '-source.png');
+exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask2.png -compose DstIn -composite -gravity East /tmp/' . $id . '.png', $out2);
+
+unlink("/tmp/temp");
+
+echo(file_get_contents('/tmp/' . $id . '.png')); \ No newline at end of file