Files
startup/inhalte/stamm_logo_edit.php

62 lines
2.0 KiB
PHP

<?php
function png2gif($pngs, $background = array(255, 255, 255))
{
foreach ($pngs as $png)
{
$size = getimagesize($png);
$img = imagecreatefrompng($png);
$image = imagecreatetruecolor($width = $size[0], $height = $size[1]);
imagefill($image, 0, 0, $bgcolor = imagecolorallocate($image, $background[0], $background[1], $background[2]));
imagecopyresampled($image, $img, 0, 0, 0, 0, $width, $height, $width, $height);
imagecolortransparent($image, $bgcolor);
imagegif($image, "img/" . PREFIX . "_logo.gif");
imagedestroy($image);
}
}
function jpg2gif($jpgs, $background = array(255, 255, 255))
{
foreach ($jpgs as $jpg)
{
$size = getimagesize($jpg);
$img = imagecreatefromjpeg($jpg);
$image = imagecreatetruecolor($width = $size[0], $height = $size[1]);
imagefill($image, 0, 0, $bgcolor = imagecolorallocate($image, $background[0], $background[1], $background[2]));
imagecopyresampled($image, $img, 0, 0, 0, 0, $width, $height, $width, $height);
imagecolortransparent($image, $bgcolor);
imagegif($image, "img/" . PREFIX . "_logo.gif");
imagedestroy($image);
}
}
if ("1" == $_POST['ok'])
{
$size = getimagesize($_FILES['Bild']['tmp_name']);
if ("image/jpeg" == $size['mime'])
{
jpg2gif(glob($_FILES['Bild']['tmp_name']));
}
elseif ("image/png" == $size['mime'])
{
png2gif(glob($_FILES['Bild']['tmp_name']));
}
else
{
echo "<h2>Sie können nur Bilder vom Typ <i>PNG, JPEG oder GIF</i> verwenden</h2>\n";
}
}
echo "<fieldset>\n";
echo " <legend>Firmenlogo</legend>\n";
if (file_exists("img/" . PREFIX . "_logo.gif"))
{
echo " <h2>Bisheriges Firmenlogo</h2>\n";
echo " <img src=\"img/" . PREFIX . "_logo.gif\" />\n";
}
echo " <form action=\"index.php?" . $_SERVER['QUERY_STRING'] . "\" method=\"post\" enctype=\"multipart/form-data\"/>\n";
echo " <input type=\"hidden\" name=\"formaction\" value=\"logo_edit\" />\n";
echo " <input type=\"file\" name=\"Bild\" />\n";
echo " <br />\n";
echo " <input type=\"submit\" class=\"button_ok\" name=\"ok\" value=\"1\" title=\"Bild hochladen\" />\n";
echo " </form>\n";
echo "</fieldset>\n";