123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/6/9
- * Time: 下午5:25
- */
- define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_ROOT_PATH . '/helper/tools/image_scaler.php');
- class TestGD extends PHPUnit_Framework_TestCase
- {
- public function testMerge()
- {
- $back_img = BASE_UPLOAD_PATH . '/tmp/back.jpg';
- $icon_img = BASE_UPLOAD_PATH . '/tmp/icon.png';
- $dest_img = BASE_UPLOAD_PATH . '/tmp/dest.jpg';
- $back = imagecreatefromjpeg($back_img);
- $icon = imagecreatefrompng($icon_img);
- imageinterlace($back);
- imagecopy($back, $icon, 60, 60, 0, 0, imagesx($icon), imagesy($icon));
- imagejpeg($back, $dest_img,100);
- }
- public function testMini()
- {
- $inimg = BASE_UPLOAD_PATH . '/upfile/20161226123858-9318573b-66b0-ac37-26ce-91e3bee30a90.png';
- $output_file = BASE_UPLOAD_PATH . '/dest.png';
- $scaler = new tools\image_scaler(400,320);
- $x = $scaler->scale($inimg,1.25);
- if($x) {
- $image = $scaler->getImage();
- imagepng($image, $output_file,0);
- // imagejpeg($image, $output_file, 100);
- @chmod($output_file,0777);
- }
- }
- public function testNo()
- {
- }
- }
|