Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Nigel_James
Active Contributor

Planning an SAP Inside Track is an excellent thing that you can do in your local area.

One of the tools in your chest to enable you to do that for the last couple of year has been the SAP Inside Track logo generator.

This is just a simple script to create a consistent style of png banner image from a couple of simple inputs.

Earlier this year this script got swept up in an overzealous administrator (me) with the delete key.

I have now re-instated the script at http://sapinsidetrack.org/_img/logo.php

There are two things you have to add. Two get parameters to the query string.

  1. year
  2. city

As an example you might have an event running in Manchester this year so with one get call to

http://sapinsidetrack.org/_img/logo.php?year=2013&city=manchester

you can get an image like this:

Then you can download the image and load it everywhere you are promoting your event.

Now just as a move to protect myself against any future overzealous administration activities. Here is the source code for the script. Enjoy.

<?php
/**
* @author Nigel James
* @email  nigel.james@sapinsidetrack.org
* @date   15 Apr 2013
*
* Create an image for SAP Inside Track events with Year and City
*/
function LoadPNG($pngName)
{
    /* Attempt to open */
    $im = @imagecreatefrompng($pngName);
    /* See if it failed */
    if(!$im)
    {
        /* Create a blank image */
        $im  = imagecreatetruecolor(150, 30);
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
        /* Output an error message */
        imagestring($im, 1, 5, 5, 'Error loading ' . $pngName, $tc);
    }
    return $im;
} // LoadPNG
// set headers
header('Content-Type: image/png');
$logo = LoadPNG('sapitlogobase.png');
// get year and city validate and  sanitise
$_year = $_GET['year'];
$_city = $_GET['city'];
// year
$yearText = (int) $_year;
if ($yearText == '0') {
    $yearText = '';
}
// city - uppercase and sanitised
$cityText = htmlspecialchars(strtoupper($_city));   
// get the text on the image
$yearColour = imagecolorallocate($logo, 0x6b, 0x6b, 0x6b); // web #6b6B6B
$cityColour = imagecolorallocate($logo, 0xF0, 0xAB, 0x00); // web #F0AB00
$font = 'ArialBold.ttf';
//imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
imagettftext($logo, 30, 0, 370, 35, $yearColour, $font, $yearText);
imagettftext($logo, 20, 0, 6, 60, $cityColour, $font, $cityText);
imagepng($logo);
imagedestroy($logo);
?>
10 Comments