mirror of
https://github.com/Tailszefox/Pony-Fusion.git
synced 2024-11-23 14:27:59 +01:00
55 lines
No EOL
1.4 KiB
PHP
55 lines
No EOL
1.4 KiB
PHP
<?php
|
|
$debug = FALSE;
|
|
|
|
include("ponies.php");
|
|
|
|
$getFrom = $_GET["from"];
|
|
$getTo = $_GET["to"];
|
|
|
|
if(!isset($ponies[$getFrom]) || !isset($ponies[$getTo]))
|
|
die("Invalid combination");
|
|
|
|
$from = imagecreatefrompng("./ponies/" . $ponies[$getFrom]["filename"]);
|
|
$to = imagecreatefrompng("./ponies/" . $ponies[$getTo]["filename"]);
|
|
|
|
for($i = 0; $i < imagecolorstotal($from); $i++)
|
|
{
|
|
if($i < imagecolorstotal($to) && $i <= 16)
|
|
{
|
|
$colorFrom = imagecolorsforindex($to, $i);
|
|
if($debug)
|
|
{
|
|
$colorTo = imagecolorsforindex($from, $i);
|
|
echo "$i\n";
|
|
print_r($colorFrom);
|
|
print_r($colorTo);
|
|
echo "\n";
|
|
}
|
|
|
|
if($getFrom == $getTo)
|
|
{
|
|
imagecolorset($from, $i, 255 - $colorFrom["red"], 255 - $colorFrom["green"], 255 - $colorFrom["blue"], $colorFrom["alpha"]);
|
|
}
|
|
else
|
|
{
|
|
imagecolorset($from, $i, $colorFrom["red"], $colorFrom["green"], $colorFrom["blue"], $colorFrom["alpha"]);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Retain transparency
|
|
imagealphablending($from, false);
|
|
imagesavealpha($from, true);
|
|
imagefill($from, 0, 0, imagecolorallocatealpha($from, 255, 255, 255, 127));
|
|
|
|
// Crop 1px from bottom to avoid showing swatch
|
|
$from = imagecrop($from, ['x' => 0, 'y' => 0, 'width' => imagesx($from), 'height' => imagesy($from) - 1]);
|
|
|
|
if(!$debug)
|
|
{
|
|
header('Content-Type: image/png');
|
|
imagepng($from);
|
|
}
|
|
|
|
imagedestroy($to);
|
|
?>
|