TestGD.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/6/9
  6. * Time: 下午5:25
  7. */
  8. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  9. require_once(BASE_ROOT_PATH . '/fooder.php');
  10. require_once(BASE_ROOT_PATH . '/helper/tools/image_scaler.php');
  11. class TestGD extends PHPUnit_Framework_TestCase
  12. {
  13. public function testMerge()
  14. {
  15. $back_img = BASE_UPLOAD_PATH . '/tmp/back.jpg';
  16. $icon_img = BASE_UPLOAD_PATH . '/tmp/icon.png';
  17. $dest_img = BASE_UPLOAD_PATH . '/tmp/dest.jpg';
  18. $back = imagecreatefromjpeg($back_img);
  19. $icon = imagecreatefrompng($icon_img);
  20. imageinterlace($back);
  21. imagecopy($back, $icon, 60, 60, 0, 0, imagesx($icon), imagesy($icon));
  22. imagejpeg($back, $dest_img,100);
  23. }
  24. public function testMini()
  25. {
  26. $inimg = BASE_UPLOAD_PATH . '/upfile/20161226123858-9318573b-66b0-ac37-26ce-91e3bee30a90.png';
  27. $output_file = BASE_UPLOAD_PATH . '/dest.png';
  28. $scaler = new tools\image_scaler(400,320);
  29. $x = $scaler->scale($inimg,1.25);
  30. if($x) {
  31. $image = $scaler->getImage();
  32. imagepng($image, $output_file,0);
  33. // imagejpeg($image, $output_file, 100);
  34. @chmod($output_file,0777);
  35. }
  36. }
  37. public function testNo()
  38. {
  39. }
  40. }