mirror of
https://github.com/Deutscher-Tischfussballbund/com_sportsmanager.git
synced 2026-06-10 14:37:52 +00:00
fix: outsource bildKopierenAngepasst method to be reused from within script.php
chore: move and rename install.php to root path and rename to script.php
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
function bildKopierenAngepasst($quelle, $ziel, $ziel_breite, $ziel_hoehe, $zuschneiden)
|
||||
{
|
||||
$len = strlen($ziel);
|
||||
if ($len < 4 || $ziel[$len - 4] != ".")
|
||||
return false;
|
||||
$ext = strtolower(substr($ziel, $len - 3));
|
||||
if ($ext != "jpg" && $ext != "png")
|
||||
return false;
|
||||
$quelle_image = $ext == "png" ? imagecreatefrompng($quelle) : imagecreatefromjpeg($quelle);
|
||||
if ($quelle_image === false)
|
||||
return false;
|
||||
$quelle_breite = imagesx($quelle_image);
|
||||
$quelle_hoehe = imagesy($quelle_image);
|
||||
if ($quelle_breite == $ziel_breite && $quelle_hoehe == $ziel_hoehe)
|
||||
return JFile::copy($quelle, $ziel);
|
||||
|
||||
$ziel_image = imagecreatetruecolor($ziel_breite, $ziel_hoehe);
|
||||
$hintergrund = $ext == "png" ? imagecolorallocatealpha($ziel_image, 0, 0, 0, 127) : imagecolorallocate($ziel_image, 64, 64, 64);
|
||||
imagefill($ziel_image, 0, 0, $hintergrund);
|
||||
$quelle_proportionen = $quelle_breite / $quelle_hoehe;
|
||||
$ziel_proportionen = $ziel_breite / $ziel_hoehe;
|
||||
if ($zuschneiden) {
|
||||
if ($ziel_proportionen >= $quelle_proportionen) {
|
||||
$quelle_teilhoehe = round($quelle_breite / $ziel_proportionen);
|
||||
if (!imagecopyresampled($ziel_image, $quelle_image, 0, 0, 0, round(($quelle_hoehe - $quelle_teilhoehe) / 2), $ziel_breite, $ziel_hoehe, $quelle_breite, $quelle_teilhoehe))
|
||||
return false;
|
||||
} else {
|
||||
$quelle_teilbreite = round($quelle_hoehe * $ziel_proportionen);
|
||||
if (!imagecopyresampled($ziel_image, $quelle_image, 0, 0, round(($quelle_breite - $quelle_teilbreite) / 2), 0, $ziel_breite, $ziel_hoehe, $quelle_teilbreite, $quelle_hoehe))
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ($ziel_proportionen >= $quelle_proportionen) {
|
||||
$ziel_teilbreite = round($ziel_hoehe * $quelle_proportionen);
|
||||
if (!imagecopyresampled($ziel_image, $quelle_image, round(($ziel_breite - $ziel_teilbreite) / 2), 0, 0, 0, $ziel_teilbreite, $ziel_hoehe, $quelle_breite, $quelle_hoehe))
|
||||
return false;
|
||||
} else {
|
||||
$ziel_teilhoehe = round($ziel_breite / $quelle_proportionen);
|
||||
if (!imagecopyresampled($ziel_image, $quelle_image, 0, round(($ziel_hoehe - $ziel_teilhoehe) / 2), 0, 0, $ziel_breite, $ziel_teilhoehe, $quelle_breite, $quelle_hoehe))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ob_start();
|
||||
if ($ext == "png") {
|
||||
imagesavealpha($ziel_image, true);
|
||||
if (!imagepng($ziel_image))
|
||||
return false;
|
||||
} else {
|
||||
if (!imagejpeg($ziel_image))
|
||||
return false;
|
||||
}
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
JFile::write($ziel, $output);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
+1603
-1603
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user