= count($words)) { $lines[] = $currentLine; break; } //Check to see if we can add another word to this line $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' . $words[$i+1]); while($metrics['textWidth'] <= $maxWidth) { //If so, do it and keep doing it! $currentLine .= ' ' . $words[++$i]; if($i+1 >= count($words)) break; $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' . $words[$i+1]); } //We can't add the next word to this line, so loop to the next line $lines[] = $currentLine; $i++; //Finally, update line height if($metrics['textHeight'] > $lineHeight) $lineHeight = $metrics['textHeight']; } return array($lines, $lineHeight); } function displayImage($quote, $person, $imageLoc) { $draw = new ImagickDraw(); $image = new Imagick(); $image->readImage($imageLoc); //grayscale //$image->modulateImage(100, 0, 100); /* Green text */ $draw->setFillColor("rgb(0,255,0)"); /* Font properties */ $draw->setFont('Bookman-DemiItalic'); $fontsize = 0.05 * $image->getimagewidth(); $draw->setFontSize( "$fontsize" ); //width = 1180 font is 50 //width = 300 font is 15 //font = slope of diff(width) + x intercept $xpos = $image->getimagewidth()/4; $ypos = $image->getimageheight()/4; $msg = '"' . $quote . '"' . " - $person"; list($lines, $lineHeight) = wordWrapAnnotation($image, $draw, $msg, $image->getimagewidth() /2); for($i = 0; $i < count($lines); $i++) { $image->annotateImage($draw, $xpos, $ypos + $i*$lineHeight, 0, $lines[$i]); } /* Give image a format */ $image->setImageFormat('png'); echo ''; } function printHalf($query) { //random $r = mysqli_query ($dbc, $query); while($row = mysqli_fetch_array($r)) { $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; $r2 = mysqli_query($dbc, $q2); while($row2 = mysqli_fetch_array($r2)) { $images = glob('../img/*'); displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]); } } echo ''; } echo '
'; echo '
'; echo '

Random Quote

'; $q ="select * from quote where visibility=true order by rand() limit 1"; $r = mysqli_query ($dbc, $q); while($row = mysqli_fetch_array($r)) { $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; $r2 = mysqli_query($dbc, $q2); while($row2 = mysqli_fetch_array($r2)) { $images = glob('../img/*'); displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]); } } echo '
'; echo '
'; echo '

Most Recent

'; $q ="select * from quote where visibility=true order by creation_date desc limit 1"; $r = mysqli_query ($dbc, $q); while($row = mysqli_fetch_array($r)) { $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; $r2 = mysqli_query($dbc, $q2); while($row2 = mysqli_fetch_array($r2)) { $images = glob('../img/*'); displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]); } } echo '
'; echo '
'; echo '
'; echo '
'; if(isset($_POST['panda'])) { displayImage($_POST['panda_quote'], $_POST['panda_name'], $images[rand(0, count($images) - 1)]); } echo '

Create a panda quote!

'; echo '

'; echo '
'; echo '
'; //profile include('user/profile.php'); echo '
'; echo '
'; ?>