mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-02-16 02:30:51 +00:00
first commit
This commit is contained in:
30
cgi-bin/saveImage.php
Normal file
30
cgi-bin/saveImage.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
include ("saveGraphHelpers.php");
|
||||
|
||||
$name = $_GET["name"];
|
||||
|
||||
if (isValidName($name))
|
||||
{
|
||||
$imageFilename = getImageFileName($name);
|
||||
$imageData = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $_POST['base64data']));
|
||||
|
||||
if (isset($_GET["x"]) && $_GET["width"] < 4000 && $_GET["height"] < 4000)
|
||||
{
|
||||
$src = imagecreatefromstring($imageData);
|
||||
$dst = imagecreatetruecolor($_GET["width"], $_GET["height"]);
|
||||
imagesavealpha($dst, true);
|
||||
imagealphablending($dst, false);
|
||||
|
||||
imagecopy($dst, $src, 0, 0, $_GET["x"], $_GET["y"], $_GET["width"], $_GET["height"]);
|
||||
imagepng($dst, $imageFilename);
|
||||
}
|
||||
else
|
||||
{
|
||||
file_put_contents($imageFilename, $imageData);
|
||||
}
|
||||
|
||||
chmod($imageFilename, 0644);
|
||||
echo ("OK");
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user