7) { #has mult colors, pick one $bglist = split(',', $bg); $rnd = rand(0, count($bglist)-1); $bg = $bglist[$rnd]; } $bg = hexdec($bg); $bgcolor = imagecolorallocate($im, ($bg>>16)&0xff, ($bg>>8)&0xff, $bg&0xff); $R = ($bg>>16)&0xff; $G = ($bg>>8)&0xff; $B = $bg&0xff; if ($R < 0x40 && $G < 0x40 && $B < 0x40) $darkbg = 1; } else $bgcolor = $white; if ($tc = $_GET['tc']) { if (strlen($tc) > 7) { #has mult colors, pick one $tclist = split(',', $tc); $rnd = rand(0, count($tclist)-1); $tc = $tclist[$rnd]; } $tc = hexdec($tc); $tipcolor = imagecolorallocate($im, ($tc>>16)&0xff, ($tc>>8)&0xff, $tc&0xff); $R = ($tc>>16)&0xff; $G = ($tc>>8)&0xff; $B = $tc&0xff; if ($R < 0x40 && $G < 0x40 && $B < 0x40) $darktc = 1; } else $tipcolor = $springgreen; if ($_GET['trans'] == 1) imagecolortransparent($ididimg, $bgcolor); $menu_color = $black; //if ($bgcolor == $black) $menu_color = $white; if ($darkbg) $menu_color = $white; imagefilledrectangle($ididimg, 0, 0, $ididx, $ididy, $bgcolor /*$hintofgreen*/); //imagecopy($ididimg, $bgim, 0, $topmarginheight, 0, 0, 400, 100); $logox = $newx*.90; $logoy = $newy*.90; $maxlogox = 80; if ($newx > $maxlogox) { $logoy = $logoy/($logox/$maxlogox); $logox = $maxlogox; } if ($ht > 0) { # scale logo if for google ad slot $logox *= ($ht/$miny); $logoy *= ($ht/$miny); } imagecopyresampled($ididimg, $im, 7,7,0,0, $logox, $logoy, $x, $y); if (!$square) { ## get a random tip #$tips = file("tips.list"); #$rnd = rand(0, count($tips)-1); #list($tipfn, $tip) = split('\|', $tips[$rnd], 2); # ensure is a valid tip filename # good for blurbs in future: #if (preg_match('/^tips\/\w+\/\d+$/', $_GET['t'])) { # $tipf = file($_GET['t']); # $tip = $tipf[0]; #} #else $tip = "Read \"$title\" and other ebooks by Andrew Burt."; $tip = "Read \"$title\"\n by Andrew Burt"; #$tip = $_GET['x']." $minx $tip"; $textleftmargin = $logox+10; $maxtiplen = 40; $bbox = imageftbbox(10, 0, 'georgiab.ttf', "$tip"); if (abs($bbox[2]-$bbox[0]) > $minx-$textleftmargin) { #was: if (strlen($tip) > $maxtiplen) { $tip = substr_replace($tip, "\n ", strrpos(substr($tip, 0, strlen($tip)/2), " "), 1); //$tip2 = substr($tip, strrpos(substr($tip, 70), " ")); //$tip = substr($tip, 0, strlen($tip)-strlen($tip2)); } // fonts: VeraBd, Vera, comic, comicbd $tipfontsize = 11.5; if (strlen($title) > 40) $tipfontsize = 11; imagettftext($ididimg, $tipfontsize, 0, $textleftmargin, $topmarginheight+13, $tipcolor, 'georgiab.ttf', "$tip"); # imagettftext($ididimg, 8, 0, $textleftmargin, $miny-40, $menu_color, 'Vera.ttf', " Get this ebook | Read More | Share | Discuss"); imagettftext($ididimg, 8, 0, $textleftmargin, $miny-40, $menu_color, 'Vera.ttf', " Get this ebook | Read More | Share | Kindle"); #$pitch = "Spread the word. Save the planet."; if (rand(0,100)+date("n")*2 >= 50) // more 'gift' toward xmas $pitch = "Give an ebook as a gift - signed and personally inscribed!"; else $pitch = "Read an ebook, save a tree."; $pitch_fontsize = 9; $pitch_font = 'Vera.ttf'; $pitch_color = $tipcolor; $bbox = imageftbbox($pitch_fontsize, 0, $pitch_font, $pitch); $pitchwid = abs($bbox[2]-$bbox[0]); imagettftext($ididimg, $pitch_fontsize, 0, $ididx-$pitchwid-10, $ididy-5, $pitch_color, $pitch_font, $pitch); } imagepng($ididimg); imagedestroy($im); //imagedestroy($bgim); imagedestroy($ididimg); ?>