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.

EffectApplyDbo.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: robin
  5. * Date: 4/22/16
  6. * Time: 4:57 PM
  7. */
  8. namespace App\Http\DBO;
  9. use Imagick;
  10. use Luticate\Utils\LuDbo;
  11. class EffectApplyDbo extends LuDbo
  12. {
  13. /**
  14. * @var Imagick
  15. */
  16. private $image;
  17. /**
  18. * @var string
  19. */
  20. private $effect;
  21. /**
  22. * @var array
  23. */
  24. private $data;
  25. public static function jsonDeserialize($json)
  26. {
  27. $dbo = new EffectApplyDbo();
  28. $imagine = new Imagick();
  29. $imagine->readImageBlob(base64_decode($json["image"]));
  30. $dbo->setImage($imagine);
  31. $dbo->setEffect($json["effect"]);
  32. $dbo->setData($json["data"]);
  33. return $dbo;
  34. }
  35. function jsonSerialize()
  36. {
  37. $imageData = null;
  38. if (!is_null($this->image)) {
  39. $imageData = base64_encode($this->image->getImageBlob());
  40. }
  41. return [
  42. "image" => $imageData,
  43. "effect" => $this->effect,
  44. "data" => $this->data
  45. ];
  46. }
  47. /**
  48. * @return Imagick
  49. */
  50. public function getImage()
  51. {
  52. return $this->image;
  53. }
  54. /**
  55. * @param Imagick $image
  56. */
  57. public function setImage($image)
  58. {
  59. $this->image = $image;
  60. }
  61. /**
  62. * @return string
  63. */
  64. public function getEffect()
  65. {
  66. return $this->effect;
  67. }
  68. /**
  69. * @param string $effect
  70. */
  71. public function setEffect($effect)
  72. {
  73. $this->effect = $effect;
  74. }
  75. /**
  76. * @return array
  77. */
  78. public function getData()
  79. {
  80. return $this->data;
  81. }
  82. /**
  83. * @param array $data
  84. */
  85. public function setData($data)
  86. {
  87. $this->data = $data;
  88. }
  89. }