-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerateAll.php
29 lines (24 loc) · 916 Bytes
/
generateAll.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
require_once('config.php');
require_once('class.Phrase.php');
require_once('class.PhrasePNGBuilder.php');
require_once('loadPhrases.php');
$pngBuilder = new PhrasePNGBuilder($textFont, $authorFont, $textSize, $authorSize, $backgroundColor, $borderColor, $textColor, $authorColor);
$counter = 0;
// Generate images for all phrases that have not been generated before
foreach (getPhrases() as $phrase) {
$text = wordwrap($phrase->phrase(), $charactersPerLine);
$author = $phrase->author();
$hash = $phrase->md5();
$imageFile = $imagesFolder . '/' . $hash . '.png';
if (!file_exists($imageFile) || isset($_REQUEST['force'])) {
$pngBuilder->phrase($phrase, $charactersPerLine);
$image = $pngBuilder->build();
// Save the image
imagepng($image, $imageFile);
// Unload resources.
imagedestroy($image);
$counter++;
}
}
echo "Generated {$counter} phrases as png files, current is: {$phrase}";