PHP code:-
<?php
header("Content-Type: image/png");
$size = NULL;
$x = NULL;
$height = NULL;
$y = NULL;
/* $fonts = array("font.ttf", "font bd.ttf");
shuffle($fonts);
$font = $fonts[0]; */
$font = "font.ttf";
if (!isset($_GET["favicon"]) && !isset($_GET['image-min'])) {
$width = NULL;
if (isset($_GET["width"]))
$width = $_GET["width"];
if ($width > 920) {
$size = 100;
$height = 110;
} elseif ($width < 920 && $width > 750) {
$size = 50;
$height = 60;
} elseif ($width < 750 && $width > 550) {
$size = 30;
$height = 40;
} else {
$size = 30;
$height = 40;
}
$im = imagecreate($width, $height);
} elseif (isset($_GET['favicon'])) {
$im = imagecreate(16, 16);
$text = "Z";
$size = 15;
} elseif (isset($_GET['image-min'])) {
$width = NULL;
$height = NULL;
if (isset($_GET['width']))
$width = $_GET['width'];
if (isset($_GET['height']))
$height = $_GET['height'];
$im = imagecreate($width, $height);
$size = 20;
if (isset($_GET['size']))
$size = $_GET['size'];
}
if (!isset($_POST['get'])) {
if (isset($_REQUEST['text'])) {
$text = $_REQUEST['text'];
} else {
$text = "Z U C K N E T";
}
$br = 46;
$bg = 49;
$bb = 146;
$tr = 0;
$tg = 0;
$tb = 0;
if (isset($_GET['br']) && isset($_GET['bg']) && isset($_GET['bb'])) {
$br = $_GET['br'];
$bg = $_GET['bg'];
$bb = $_GET['bb'];
}
if (isset($_GET['tr']) && isset($_GET['tg']) && isset($_GET['tb'])) {
$tr = $_GET['tr'];
$tg = $_GET['tg'];
$tb = $_GET['tb'];
}
$background = imagecolorallocate($im, $br, $bg, $bb);
$textclr = imagecolorallocate($im, $tr, $tg, $tb);
$bbox = imagettfbbox($size, 0, $font, $text);
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2);
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2);
imagettftext($im, $size, 0, $x, $y, $textclr, $font, strtolower($text));
imagepng($im);
imagedestroy($im);
} else {
echo $height;
}
?>
Using with <img>:-
<img src="logo.php?logo-min&width=500&height=200&size=48&br=51&bg=51&bb=51&tr=255&tg=255&tb=255"/>
<?php
header("Content-Type: image/png");
$size = NULL;
$x = NULL;
$height = NULL;
$y = NULL;
/* $fonts = array("font.ttf", "font bd.ttf");
shuffle($fonts);
$font = $fonts[0]; */
$font = "font.ttf";
if (!isset($_GET["favicon"]) && !isset($_GET['image-min'])) {
$width = NULL;
if (isset($_GET["width"]))
$width = $_GET["width"];
if ($width > 920) {
$size = 100;
$height = 110;
} elseif ($width < 920 && $width > 750) {
$size = 50;
$height = 60;
} elseif ($width < 750 && $width > 550) {
$size = 30;
$height = 40;
} else {
$size = 30;
$height = 40;
}
$im = imagecreate($width, $height);
} elseif (isset($_GET['favicon'])) {
$im = imagecreate(16, 16);
$text = "Z";
$size = 15;
} elseif (isset($_GET['image-min'])) {
$width = NULL;
$height = NULL;
if (isset($_GET['width']))
$width = $_GET['width'];
if (isset($_GET['height']))
$height = $_GET['height'];
$im = imagecreate($width, $height);
$size = 20;
if (isset($_GET['size']))
$size = $_GET['size'];
}
if (!isset($_POST['get'])) {
if (isset($_REQUEST['text'])) {
$text = $_REQUEST['text'];
} else {
$text = "Z U C K N E T";
}
$br = 46;
$bg = 49;
$bb = 146;
$tr = 0;
$tg = 0;
$tb = 0;
if (isset($_GET['br']) && isset($_GET['bg']) && isset($_GET['bb'])) {
$br = $_GET['br'];
$bg = $_GET['bg'];
$bb = $_GET['bb'];
}
if (isset($_GET['tr']) && isset($_GET['tg']) && isset($_GET['tb'])) {
$tr = $_GET['tr'];
$tg = $_GET['tg'];
$tb = $_GET['tb'];
}
$background = imagecolorallocate($im, $br, $bg, $bb);
$textclr = imagecolorallocate($im, $tr, $tg, $tb);
$bbox = imagettfbbox($size, 0, $font, $text);
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2);
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2);
imagettftext($im, $size, 0, $x, $y, $textclr, $font, strtolower($text));
imagepng($im);
imagedestroy($im);
} else {
echo $height;
}
?>
Using with <img>:-
<img src="logo.php?logo-min&width=500&height=200&size=48&br=51&bg=51&bb=51&tr=255&tg=255&tb=255"/>
Comments