Skip to content

Instantly share code, notes, and snippets.

@dmzoneill
Created September 23, 2023 14:03
Show Gist options
  • Save dmzoneill/67a908fb949dc95bbbf02f0446a07f0a to your computer and use it in GitHub Desktop.
Save dmzoneill/67a908fb949dc95bbbf02f0446a07f0a to your computer and use it in GitHub Desktop.
durex fun
<?php
if(isset($_GET['tname'])) {
$name = $_GET['tname'];
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('orig.jpg');
// Allocate A Color For The Text
$black = imagecolorallocate($jpg_image, 92, 92, 92);
// Allocate A Color For The Text
$grey = imagecolorallocate($jpg_image, 192, 192, 192);
// Set Path to Font File
$font_path = '/home/dave/www/feeditout.com/danica/font.ttf';
// Set Text to Be Printed On Image
$text = $name;
// Print Text shadow
$res = imagettftext($jpg_image, 35, -20, 316, 426, $grey, $font_path, $text);
// Print Text On Image
$res = imagettftext($jpg_image, 35, -20, 318, 428, $black, $font_path, $text);
// Send Image to Browser
$res = imagejpeg($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
}
else {
$name = isset($_GET['name']) ? $_GET['name'] : "Daryll";
print("<html><body><img src='index.php?tname=" . $name . "'/></body></html>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment