Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Info.php
1<?php
10
11use \Bitrix\Main\File\Image;
12
13class Info
14{
15 protected
21
25 public function getWidth()
26 {
27 return $this->width;
28 }
29
34 public function setWidth($width)
35 {
36 $this->width = $width;
37 return $this;
38 }
39
43 public function getHeight()
44 {
45 return $this->height;
46 }
47
52 public function setHeight($height)
53 {
54 $this->height = $height;
55 return $this;
56 }
57
61 public function getFormat()
62 {
63 return $this->format;
64 }
65
70 public function setFormat($format)
71 {
72 $this->format = $format;
73 return $this;
74 }
75
79 public function getAttributes()
80 {
81 return "width=\"{$this->getWidth()}\" height=\"{$this->getHeight()}\"";
82 }
83
87 public function getMime()
88 {
89 return $this->mime;
90 }
91
96 public function setMime($mime)
97 {
98 $this->mime = $mime;
99 return $this;
100 }
101
106 public function swapSides()
107 {
108 $tmp = $this->getHeight();
109 $this->setHeight($this->getWidth())
110 ->setWidth($tmp);
111 return $this;
112 }
113
118 public function isSupported()
119 {
120 static $knownTypes = null;
121
122 if($knownTypes === null)
123 {
124 $knownTypes = [
129 ];
130 if(function_exists("imagecreatefromwebp"))
131 {
132 $knownTypes[Image::FORMAT_WEBP] = 1;
133 }
134 }
135
136 return isset($knownTypes[$this->getFormat()]);
137 }
138
143 public function toRectangle()
144 {
145 return new Rectangle($this->getWidth(), $this->getHeight());
146 }
147}