Skip to content

Instantly share code, notes, and snippets.

@Kcko
Last active August 29, 2015 14:05
Show Gist options
  • Save Kcko/490f9aacd92d33470689 to your computer and use it in GitHub Desktop.
Save Kcko/490f9aacd92d33470689 to your computer and use it in GitHub Desktop.
Psaní do obrázků - PHP
<?php
$im = imagecreatefromjpeg("match-trailer.jpg");
$font = 'fonts/calibrib.ttf';
$fontNormal = 'fonts/calibri.ttf';
$teams = mb_strtoupper("FC Combix - FC Bohemians Praha B", 'UTF-8');
$white = ImageColorAllocate($im, 255, 255, 255);
$orange = ImageColorAllocate($im, 255, 127, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// Týmy
ImagettfText($im, $fontSize = 34, 0, 30, 80, $white, $font, $teams);
// Kde
ImagettfText($im, $fontSize = 20, 0, 30, 170, $orange, $font, 'KDY:');
ImagettfText($im, $fontSize = 20, 0, 95, 170, $white, $fontNormal, '25.8.2014');
// Kde
ImagettfText($im, $fontSize = 20, 0, 30, 220, $orange, $font, 'KDE:');
ImagettfText($im, $fontSize = 20, 0, 95, 220, $white, $fontNormal, 'Stadiony Bohemians, Přípotoční 27/a');
// Vstupné
ImagettfText($im, $fontSize = 24, 0, 30, 420, $black, $font, 'VSTUPNÉ:');
ImagettfText($im, $fontSize = 30, 0, 180, 420, $orange, $font, '60 Kč');
// Vystup
imageJpeg($im, "upoutavka.jpg");
ImageDestroy($im);
header('Content-type: image/jpg');
echo $image;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment