您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ImageUploadDbo.php 1.3KB

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