| 
<?php
ini_set( 'display_errors', 1 );
 error_reporting(E_ALL ^ E_NOTICE);
 
 include '../imager.php';
 
 $p = new Imager( new AutoFileInput( 'img/main.jpg') );
 $p2= new Imager( new Canvas( 250, 250 ));
 
 $tests = array(
 '$p->darkness()->save( new JPEG("out/0.jpg") );',
 '$p->noise()->save( new JPEG("out/1.jpg") );',
 '$p->pixelate( 4 )->save( new JPEG("out/2.jpg") );',
 '$p->watermark( new Imager( new PNG("img/doggy.png") ), Imager::BOTTOM_RIGHT )->save( new JPEG("out/3.jpg") );',
 '$p->addImage( new PNG("img/doggy.png"), 30, 10 )->save( new JPEG( "out/4.jpg" ) );',
 '$p->scaleTo( "box", array( 100, 100 ) )->save( new JPEG( "out/5.jpg") );',
 '$p->rotate( 90 )->save( new JPEG( "out/6.jpg" ) );',
 '$p->rotate( 45 )->save( new JPEG("out/7.jpg") );',
 '$p->rotate( 45, array( 30,60,80 ) )->save( new JPEG("out/8.jpg") );',
 '$p->grayscale()->save( new JPEG("out/9.jpg") );',
 '$p->negate()->save( new JPEG("out/10.jpg") );',
 '$p->blur()->save( new JPEG( "out/11.jpg" ) );',
 '$p->flipV()->save( new JPEG( "out/12.jpg" ) );',
 '$p->flipH()->save( new JPEG( "out/13.jpg" ) );',
 '$p->watermark( new Imager( new PNG( "img/doggy.png" ) ), Imager::TOP_LEFT )->save( new JPEG( "out/14.jpg" ) );',
 '$p->watermark( new Imager( new PNG( "img/skorpalpha.png" ), new Transparency( true ) ), Imager::CENTER )->save( new JPEG( "out/15.jpg") );',
 '$p->watermark( new Imager( new PNG( "img/ok.png" ), new Transparency( array( 51, 255, 51 ) ) ), Imager::BOTTOM_RIGHT )->save( new JPEG( "out/16.jpg" ) );',
 '$p->thumb( new JPEG( "img/main.jpg" ) )->save( new JPEG( "out/17.jpg" ) );',
 '$p->scaleTo( "width", 400 )->save( new JPEG( "out/18.jpg" ) );',
 '$p2 = new Imager( new Canvas( 170, 200 ) ); $p2->fillTo( new Imager( new AutoFileInput( "img/main.jpg" ) ), false )->save( new JPEG( "out/19.jpg") );',
 '$p2 = new Imager( new Canvas( 170, 200 ) ); $p2->fillTo( new Imager( new AutoFileInput( "img/main.jpg" ) ), true )->save( new JPEG( "out/20.jpg") );',
 '$p->autothreshold()->flipV()->save( new JPEG( "out/21.jpg" ) );',
 '$p->sketch()->save( new JPEG( "out/22.jpg" ) );',
 '$p->sepia()->save( new JPEG( "out/23.jpg" ) );',
 '$p->emboss()->save( new JPEG( "out/24.jpg" ) );',
 '$p->edgeTopDown()->save( new JPEG( "out/25.jpg" ) );',
 '$p->edgeHorizontal()->save( new JPEG( "out/26.jpg" ) );',
 '$p->edgeHorizontal()->edgeVertical()->save( new JPEG( "out/27.jpg" ) );',
 '$p->laplace()->save( new JPEG( "out/28.jpg" ) );',
 '$p->resize( 200, 100 )->flipH()->gamma()->save( new JPEG( "out/29.jpg" ) );',
 '$p->sobelhorizontal()->save( new JPEG( "out/30.jpg" ) );',
 '$p->sobelvertical()->save( new JPEG( "out/31.jpg" ) );',
 '$p->sobelhorizontal()->sobelvertical()->save( new JPEG( "out/32.jpg" ) );',
 '$p->hipass()->save( new JPEG( "out/33.jpg" ) );',
 '$height = 16; $text_name_full_width=100;
 $img_inner = new Imager( new PNG( "img/pic_inner.png" ), new Transparency( true ) );
 $img_inner = $img_inner->resize( 2 * $img_inner->width, 2 * $height );
 $img_inner_name = $img_inner->resize( 2 * $text_name_full_width, 2 * $height );
 $img_left = new Imager( new PNG( "img/pic_left.png" ), new Transparency( true ) );
 $img_left = $img_left->scaleTo( "height", 2 * $height );
 $img_right = new Imager( new PNG( "img/pic_right.png" ), new Transparency( true ) );
 $img_right = $img_right->scaleTo( "height", 2 * $height );
 $img_name = $img_left->addImage( $img_inner_name, $img_left->width, 0)
 ->addImage( $img_right, $img_left->width + $img_inner_name->width , 0);
 $img_name->save( new PNG( "out/34.png" ) );',
 '$points = array(
 array( "x" => 38, "y" => 219 ),
 array( "x" => 170, "y" => 182 ),
 array( "x" => 284, "y" => 194 ),
 array( "x" => 390, "y" => 219 ) );
 $q = new Imager( new Canvas( 500, 250, array( 200, 0, 0 ) ), new Transparency( array( 200, 0, 0 ) ) );
 $q->bezier( $points, 100, 2, array( 0, 0, 0 ) )->save( new PNG( "out/35.png" ) );',
 '$str = "Marisa Miller";
 $rect = $p->setFontPath( "./img" )->textRectangle( $str, 14 );
 $textpos = array( "x" => ( ( $p->width - $rect[ "lower_right_x" ] ) / 2 ), "y" => ( ( $p->height + $rect[ "upper_right_y" ] ) / 2 ) );
 $p->drawText( $str, $textpos[ "x" ], $textpos[ "y" ], false, 14, 0, array( 0xFE, 0xF2, 0x2A ) )
 ->save( new PNG( "out/36.png" ) );',
 '$p->crop( 0, 0, 50, 80 )->save( new JPEG("out/37.jpg") );',
 '$im = new Imager( new PNG( "img/skorpalpha.png" ), new Transparency( true ) );
 $im = $im->resize( 60, 60 );
 $p->watermark( $im, Imager::BOTTOM_RIGHT )->save( new JPEG( "out/38.jpg") );',
 '$p->addAlpha( new JPEG( "img/alphachannel.jpg" ) )->save( new PNG( "out/39.png" ) );',
 '$p2->addAlpha( new JPEG( "img/alphachannel.jpg" ) )->flipV()->save( new PNG( "out/40.png" ) );',
 '$p->addAlpha( new JPEG( "img/alphachannel.jpg" ) )->negate()->save( new PNG( "out/41.png" ) );',
 '$p->addAlpha( new JPEG( "img/alphachannel.jpg" ) )->autothreshold()->save( new PNG( "out/42.png" ) );',
 '$p->rotate( 45, array(0,0,0), 0 )->save( new PNG("out/43.png") );',
 '$p->rotate( 45 )->crop( 0, 0, 150, 150 )
 ->save( new PNG("out/44.png") );',
 '$wu = min( $p->width, $p->height );
 $im = $p->watermark( new Imager( new PNG("img/skorpalpha.png"), new Transparency( true ) ), Imager::CENTER )->rotate( 45 );
 $w = $im->width; $h = $im->height;
 $im->crop( ($w-$wu) / 2, ($h-$wu)/2, $wu, $wu )->watermark( new Imager( new PNG("img/skorpalpha.png"), new Transparency( true ) ), Imager::BOTTOM_RIGHT )
 ->save( new PNG("out/45.png") );',
 '$points = array(
 array( "x" => 38, "y" => 219 ),
 array( "x" => 170, "y" => 182 ),
 array( "x" => 284, "y" => 194 ),
 array( "x" => 390, "y" => 219 ) );
 $q = new Imager( new Canvas( 500, 250, array( 200, 0, 0 ) ), new Transparency( array( 200, 0, 0 ) ) );
 $q->bezier( $points, 100, 2, array( 0, 0, 0 ) )->save( new PNG( "out/46.png" ) );',
 );
 
 
 if ( array_key_exists( 'testnum', $_GET ) ) {
 $i = basename( $_GET[ 'testnum' ] );
 settype( $i, 'integer' );
 eval( $tests[ $i ] );
 if ( file_exists( "out/{$i}.jpg" ) ) {
 echo readfile( "out/{$i}.jpg" );
 } if ( file_exists( "out/{$i}.png" ) ) {
 echo readfile( "out/{$i}.png" );
 }
 } else {
 ?><table border="1" style="background-color: yellow">
 <?php
 foreach( $tests as $k => $row ) {
 ?>
 <tr>
 <td><?php echo $k ?></td>
 <td><img src="test_allinone.php?testnum=<?php echo $k; ?>"/></td>
 <td><?php echo $row ?></td>
 </tr>
 <?php
 }
 ?><table><?php
 }
 ?>
 |