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.

DummyCamera.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: robin
  5. * Date: 11/24/15
  6. * Time: 12:56 PM
  7. */
  8. namespace App\Http\Business\Cameras;
  9. use App\Http\DBO\CamerasDbo;
  10. use App\Http\DBO\CamerasImageDbo;
  11. use Imagine\Image\Box;
  12. use Imagine\Image\Palette\RGB;
  13. use Imagine\Image\Point;
  14. use Imagine\Imagick\Image;
  15. use Imagine\Imagick\Imagine;
  16. class DummyCamera extends AbstractCamera
  17. {
  18. /**
  19. * @var $_image Image
  20. */
  21. private $_image;
  22. /**
  23. * @var $_imagine Imagine
  24. */
  25. private $_imagine;
  26. public function __construct(CamerasDbo $camera)
  27. {
  28. parent::__construct($camera);
  29. $this->_imagine = new Imagine();
  30. $this->_image = $this->_imagine->open("../resources/images/dummy_camera.jpg");
  31. }
  32. /**
  33. * @return CamerasImageDbo
  34. */
  35. public function getImage()
  36. {
  37. $imageDbo = new CamerasImageDbo();
  38. $draw = $this->_image->draw();
  39. $palette = new RGB();
  40. $radius = rand(10, 42);
  41. $draw->ellipse(new Point(42, 42), new Box($radius, $radius), $palette->color('#ff0000'));
  42. $imageDbo->setImage(base64_encode($this->_image->get("jpeg")));
  43. return $imageDbo;
  44. }
  45. }