Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CropTest.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace tests;
  12. use think\Image;
  13. class CropTest extends TestCase
  14. {
  15. public function testJpeg()
  16. {
  17. $pathname = TEST_PATH . 'tmp/crop.jpg';
  18. $image = Image::open($this->getJpeg());
  19. $image->crop(200, 200, 100, 100, 300, 300)->save($pathname);
  20. $this->assertEquals(300, $image->width());
  21. $this->assertEquals(300, $image->height());
  22. $file = new \SplFileInfo($pathname);
  23. $this->assertTrue($file->isFile());
  24. @unlink($pathname);
  25. }
  26. public function testPng()
  27. {
  28. $pathname = TEST_PATH . 'tmp/crop.png';
  29. $image = Image::open($this->getPng());
  30. $image->crop(200, 200, 100, 100, 300, 300)->save($pathname);
  31. $this->assertEquals(300, $image->width());
  32. $this->assertEquals(300, $image->height());
  33. $file = new \SplFileInfo($pathname);
  34. $this->assertTrue($file->isFile());
  35. @unlink($pathname);
  36. }
  37. public function testGif()
  38. {
  39. $pathname = TEST_PATH . 'tmp/crop.gif';
  40. $image = Image::open($this->getGif());
  41. $image->crop(200, 200, 100, 100, 300, 300)->save($pathname);
  42. $this->assertEquals(300, $image->width());
  43. $this->assertEquals(300, $image->height());
  44. $file = new \SplFileInfo($pathname);
  45. $this->assertTrue($file->isFile());
  46. @unlink($pathname);
  47. }
  48. }