Byron Posted April 25, 2011 Share Posted April 25, 2011 A friend of mine wrote this and it's still kind of a work in progress as you can see stuff commented out but this is what he's got so far. Requires the font below. http://byrondallas.heliohost.org/php/fonts/lokicola.ttf <?php $rand = rand(1, 100000); $file = "$rand.logo.gif"; $font = "lokicola.ttf"; if ( $_GET ) { $w = $_GET[w]; $h = $_GET[h]; $f = $_GET[f]; # number of frames $size = $_GET[size]; $delay = $_GET[del]; if ($f < 1) { $move = 0; $f = 1; } else { $move = $w/$f; } # new imagick object $img = new Imagick(); # remove NULL's from colors foreach ($_GET[c] as $temp ) { if ( strlen($temp) > 0 ) { $colors[] = $temp; } } # how many colors? $n = count($colors); # make gradients till next to last color for ($x=0; $x<$n-1; $x++) { $next = $x+1; $gradient = "gradient:$colors[$x]-$colors[$next]"; $img->newPseudoImage( 100, 100, "$gradient" ); } # loop last color back to first color $last = $n-1; $gradient = "gradient:$colors[$last]-$colors[0]"; $img->newPseudoImage( 100, 100, "$gradient" ); # go back to top of stack and append $img->resetIterator(); $bar = $img->appendImages(true); # rotate & resize $bar->rotateImage(new ImagickPixel(), 270); # $bar->scaleimage($w, $h, FALSE ); # new object for frames $frames = new Imagick(); for ($x=0; $x<$f; $x++) { # roll, resize and add to frames $bar->rollimage( $move, 0 ); $bar->scaleimage($w, $h, FALSE ); $frames->addimage($bar); $frames->setImageDelay("$delay"); } if ($_GET[swirl] == "on") { $m = max( array($w,$h) ); foreach ($frames as $temp) { /* if ($_GET[transbg] == "on") { $temp->setimagebackgroundcolor("transparent"); $temp->setImageVirtualPixelMethod( imagick::VIRTUALPIXELMETHOD_TRANSPARENT ); } */ $temp->scaleimage($m, $m, FALSE ); $temp->distortImage( Imagick::DISTORTION_ARC, array( 361 ), TRUE ); $temp->swirlimage( max(0,$_GET[deg]) ); $temp->scaleimage($w, $h, FALSE ); } } ############################ if ($_GET[reverse] == "on") { foreach ($frames as $temp) { $orig = $temp->clone(); $flop = $temp->clone(); $flop->flopImage(); $orig->addimage($flop); $orig->appendImages(false); #$temp->destroy(); #$temp = new Imagick(); #$temp->addimage($orig); } } ############################ /* ############################ if ($_GET[reflect] == "on") $reflection = new Imagick(); foreach ($frames as $temp) { { $orig = $temp->clone(); $flop = $temp->clone(); # $temp->removeimage(); # debug $orig = $temp->clone(); $flop->flopImage(); $reflection->addimage($orig); $reflection->addimage($flop); # $temp->destroy(); # $temp = new Imagick(); # $temp->addimage($orig); # $temp->addimage($flop); $reflection->appendImages(false); $temp->setImageFormat('gif'); $flop->setImageFormat('gif'); $reflection->setImageFormat('gif'); #$new->setImageFormat('gif'); header( "Content-Type: image/gif" ); echo $reflection; exit; } #$reflection->resetIterator(); #$reflection->appendImages(true); $reflection->writeimages( "$file", TRUE); header( "location:$file" ); } ############################## */ ############################## if ($_GET[txt] == "on") { $logo = new Imagick(); foreach ($frames as $temp) { $logo->newimage($w,$h, "transparent"); $draw = new ImagickDraw(); $draw->setfont("$font"); # set font $draw->setfillcolor("#0000ff"); $draw->setgravity(imagick::GRAVITY_CENTER); $draw->setFontSize( $size ); # annotate #$draw->annotation( 0, 0, "$_GET[text_entered]" ); $logo->annotateImage ( $draw,0 ,0, 0, "$_GET[text_entered]" ); $logo->drawImage( $draw ); $logo->compositeImage( $temp, imagick::COMPOSITE_ATOP, 0,0 ); } $logo->setImageFormat('gif'); $logo->writeimages("$file", TRUE); header( "location:$file" ); exit; } ############################## # set the image format to gif $bar->setImageFormat('gif'); # Write final image $frames->writeimages("$file", TRUE); header( "location:$file" ); exit; } ?> <html> <head><title>Rainbow Text Maker</title></head> <body> <form> <input type="text" name="w" size="3" value="500"> Width<br> <input type="text" name="h" size="3" value="100"> Height<br> <input type="text" name="size" size="3" value="90"> Font Size<br> <input type="text" name="f" size="3" value="10"> Frames<br> <input type="text" name="del" size="3" value="3"> Delay<br> Colors<br> <input type="text" name="c[]" value="#ff0000"><br> <input type="text" name="c[]" value="#ff8800"><br> <input type="text" name="c[]" value="#ffff00"><br> <input type="text" name="c[]" value=""><br> <input type="text" name="c[]" value="#00ff00"><br> <input type="text" name="c[]" value=""><br> <input type="text" name="c[]" value="#00ffff"><br> <input type="text" name="c[]" value="#0088ff"><br> <input type="text" name="c[]" value="#0000ff"><br> <input type="text" name="c[]" value="#8800ff"><br> Options:<br> <input type="checkbox" name="swirl" checked> Swirl <input type="text" size="3" name="deg" value="99"> Degrees <br> <input type="checkbox" name="txt" checked> Text: <input type="text" name="text_entered" value=""> <br> <input type="submit"><br> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
jje Posted April 25, 2011 Share Posted April 25, 2011 Woah - that script is amazing! Thanks for sharing it with us! Quote Link to comment Share on other sites More sharing options...
Byron Posted April 25, 2011 Author Share Posted April 25, 2011 That script is written as a form so you can try many different variations. btw, this is the Imagick portion of my friend's site showing some really good examples of what can be done with the Imagick Class. http://eclecticdjs.com/mike/tutorials/php/imagemagick/ Quote Link to comment Share on other sites More sharing options...
Guest Geoff Posted April 25, 2011 Share Posted April 25, 2011 Really nice script. Quote Link to comment Share on other sites More sharing options...
kingdragonz Posted April 27, 2011 Share Posted April 27, 2011 wow nice script Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.