Advertisement
zenware

Random Image Generator

Feb 20th, 2012
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2. header("Content-type: image/png");
  3. putenv('GDFONTPATH=' . realpath('.'));
  4.  
  5. // Randomize Values
  6. $randImage = rand(1,10);
  7. $randSize = rand(15,20);
  8. $randAngle = rand(-7,7);
  9. $randR = rand(0,255);
  10. $randG = rand(0,255);
  11. $randB = rand(0,255);
  12. $quote = file("quotes.txt");
  13. $quoteCount = count($quote);
  14. $randQuote = rand(0, $quoteCount - 1);
  15.  
  16. // Assign Random Values to Variables
  17. $image = imagecreatefrompng("pngs/$randImage.png");
  18. $size = $randSize;
  19. $angle = $randAngle;
  20. $posX = 150;
  21. $posY = 80;
  22. $color = imagecolorallocate($image, $randR, $randG, $randB);
  23. $font = 'fonts/Glass_TTY_VT220';
  24. $string = html_entity_decode($quote[$randQuote]);
  25.  
  26. // Load Image/Text using the Previously Assigned Variables...
  27. imagettftext ($image, $size, $angle, $posX, $posY, $color, $font, $string);
  28. imagepng($image);
  29. imagedestroy($image);
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement