00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00018 final class PrimitiveImage extends PrimitiveFile
00019 {
00020 private $width = null;
00021 private $height = null;
00022
00023 private $maxWidth = null;
00024 private $minWidth = null;
00025
00026 private $maxHeight = null;
00027 private $minHeight = null;
00028
00029 private $type = null;
00030
00034 public function clean()
00035 {
00036 $this->width = $this->height = null;
00037
00038 $this->type = null;
00039
00040 return parent::clean();
00041 }
00042
00043 public function getWidth()
00044 {
00045 return $this->width;
00046 }
00047
00048 public function getHeight()
00049 {
00050 return $this->height;
00051 }
00052
00053 public function getType()
00054 {
00055 return $this->type;
00056 }
00057
00061 public function setMaxWidth($max)
00062 {
00063 $this->maxWidth = $max;
00064
00065 return $this;
00066 }
00067
00071 public function setMinWidth($min)
00072 {
00073 $this->minWidth = $min;
00074
00075 return $this;
00076 }
00077
00081 public function setMaxHeight($max)
00082 {
00083 $this->maxHeight = $max;
00084
00085 return $this;
00086 }
00087
00091 public function setMinHeight($min)
00092 {
00093 $this->minHeight = $min;
00094
00095 return $this;
00096 }
00097
00098 public function import($scope)
00099 {
00100 if (!$result = parent::import($scope))
00101 return $result;
00102
00103 try {
00104 list($width, $height, $type) = getimagesize($this->value);
00105 } catch (BaseException $e) {
00106
00107 return false;
00108 }
00109
00110 if (!$width || !$height || !$type) {
00111 $this->value = null;
00112 return false;
00113 }
00114
00115 if (
00116 !($this->maxWidth && ($width > $this->maxWidth))
00117 && !($this->minWidth && ($width < $this->minWidth))
00118 && !($this->maxHeight && ($height > $this->maxHeight))
00119 && !($this->minHeight && ($height < $this->minHeight))
00120 ) {
00121 $this->type = new ImageType($type);
00122 $this->width = $width;
00123 $this->height = $height;
00124
00125 return true;
00126 }
00127
00128 return false;
00129 }
00130 }
00131 ?>