@@ 147-176 (lines=30) @@ | ||
144 | * @test |
|
145 | * @covers ::resize |
|
146 | */ |
|
147 | public function resizeUpsizeToMoreHorizontalAspectWithGrow() |
|
148 | { |
|
149 | $source = new \Imagick('pattern:gray0'); |
|
150 | $source->scaleImage(100, 50); |
|
151 | ||
152 | $imagick = Image::resize($source, 400, 100, ['upsize' => true]); |
|
153 | ||
154 | //making sure source didnt resize |
|
155 | $this->assertSame(100, $source->getImageWidth()); |
|
156 | $this->assertSame(50, $source->getImageHeight()); |
|
157 | ||
158 | $this->assertSame(400, $imagick->getImageWidth()); |
|
159 | $this->assertSame(100, $imagick->getImageHeight()); |
|
160 | ||
161 | $whiteBarLeft = $imagick->getImagePixelColor(99, 49)->getHsl(); |
|
162 | $whiteBarRight = $imagick->getImagePixelColor(300, 49)->getHsl(); |
|
163 | ||
164 | $imageTop = $imagick->getImagePixelColor(249, 0)->getHsl(); |
|
165 | $imageBottom = $imagick->getImagePixelColor(249, 99)->getHsl(); |
|
166 | $imageLeft = $imagick->getImagePixelColor(100, 49)->getHsl(); |
|
167 | $imageRight = $imagick->getImagePixelColor(299, 49)->getHsl(); |
|
168 | ||
169 | $this->assertGreaterThan(0.9, $whiteBarLeft['luminosity']); |
|
170 | $this->assertGreaterThan(0.9, $whiteBarRight['luminosity']); |
|
171 | ||
172 | $this->assertLessThan(0.1, $imageLeft['luminosity']); |
|
173 | $this->assertLessThan(0.1, $imageRight['luminosity']); |
|
174 | $this->assertLessThan(0.1, $imageTop['luminosity']); |
|
175 | $this->assertLessThan(0.1, $imageBottom['luminosity']); |
|
176 | } |
|
177 | ||
178 | /** |
|
179 | * Upsize ratio 2.0 to 4.0 |
|
@@ 73-102 (lines=30) @@ | ||
70 | * @test |
|
71 | * @covers ::resize |
|
72 | */ |
|
73 | public function resizeDownsizeToMoreHorizontalAspect() |
|
74 | { |
|
75 | $source = new \Imagick('pattern:gray0'); |
|
76 | $source->scaleImage(100, 50); |
|
77 | ||
78 | $imagick = Image::resize($source, 40, 10); |
|
79 | ||
80 | //making sure source didnt resize |
|
81 | $this->assertSame(100, $source->getImageWidth()); |
|
82 | $this->assertSame(50, $source->getImageHeight()); |
|
83 | ||
84 | $this->assertSame(40, $imagick->getImageWidth()); |
|
85 | $this->assertSame(10, $imagick->getImageHeight()); |
|
86 | ||
87 | $whiteBarLeft = $imagick->getImagePixelColor(9, 4)->getHsl(); |
|
88 | $whiteBarRight = $imagick->getImagePixelColor(30, 4)->getHsl(); |
|
89 | ||
90 | $imageLeft = $imagick->getImagePixelColor(10, 4)->getHsl(); |
|
91 | $imageRight = $imagick->getImagePixelColor(29, 4)->getHsl(); |
|
92 | $imageTop = $imagick->getImagePixelColor(19, 0)->getHsl(); |
|
93 | $imageBottom = $imagick->getImagePixelColor(19, 9)->getHsl(); |
|
94 | ||
95 | $this->assertGreaterThan(0.9, $whiteBarLeft['luminosity']); |
|
96 | $this->assertGreaterThan(0.9, $whiteBarRight['luminosity']); |
|
97 | ||
98 | $this->assertLessThan(0.1, $imageLeft['luminosity']); |
|
99 | $this->assertLessThan(0.1, $imageRight['luminosity']); |
|
100 | $this->assertLessThan(0.1, $imageTop['luminosity']); |
|
101 | $this->assertLessThan(0.1, $imageBottom['luminosity']); |
|
102 | } |
|
103 | ||
104 | /** |
|
105 | * Upsize ratio 2.0 to 4.0 |
|
@@ 110-139 (lines=30) @@ | ||
107 | * @test |
|
108 | * @covers ::resize |
|
109 | */ |
|
110 | public function resizeUpsizeToMoreHorizontalAspectWithoutGrow() |
|
111 | { |
|
112 | $source = new \Imagick('pattern:gray0'); |
|
113 | $source->scaleImage(100, 50); |
|
114 | ||
115 | $imagick = Image::resize($source, 400, 100); |
|
116 | ||
117 | //making sure source didnt resize |
|
118 | $this->assertSame(100, $source->getImageWidth()); |
|
119 | $this->assertSame(50, $source->getImageHeight()); |
|
120 | ||
121 | $this->assertSame(400, $imagick->getImageWidth()); |
|
122 | $this->assertSame(100, $imagick->getImageHeight()); |
|
123 | ||
124 | $whiteBarLeft = $imagick->getImagePixelColor(99, 49)->getHsl(); |
|
125 | $whiteBarRight = $imagick->getImagePixelColor(300, 49)->getHsl(); |
|
126 | ||
127 | $imageTop = $imagick->getImagePixelColor(200, 26)->getHsl(); |
|
128 | $imageBottom = $imagick->getImagePixelColor(200, 74)->getHsl(); |
|
129 | $imageLeft = $imagick->getImagePixelColor(151, 50)->getHsl(); |
|
130 | $imageRight = $imagick->getImagePixelColor(249, 50)->getHsl(); |
|
131 | ||
132 | $this->assertGreaterThan(0.9, $whiteBarLeft['luminosity']); |
|
133 | $this->assertGreaterThan(0.9, $whiteBarRight['luminosity']); |
|
134 | ||
135 | $this->assertLessThan(0.1, $imageLeft['luminosity']); |
|
136 | $this->assertLessThan(0.1, $imageRight['luminosity']); |
|
137 | $this->assertLessThan(0.1, $imageTop['luminosity']); |
|
138 | $this->assertLessThan(0.1, $imageBottom['luminosity']); |
|
139 | } |
|
140 | ||
141 | /** |
|
142 | * Upsize ratio 2.0 to 4.0 |
|
@@ 184-213 (lines=30) @@ | ||
181 | * @test |
|
182 | * @covers ::resize |
|
183 | */ |
|
184 | public function resizeUpsizeToMoreVerticalAspect() |
|
185 | { |
|
186 | $source = new \Imagick('pattern:gray0'); |
|
187 | $source->scaleImage(100, 50); |
|
188 | ||
189 | $imagick = Image::resize($source, 200, 400); |
|
190 | ||
191 | //making sure source didnt resize |
|
192 | $this->assertSame(100, $source->getImageWidth()); |
|
193 | $this->assertSame(50, $source->getImageHeight()); |
|
194 | ||
195 | $this->assertSame(200, $imagick->getImageWidth()); |
|
196 | $this->assertSame(400, $imagick->getImageHeight()); |
|
197 | ||
198 | $whiteBarLeft = $imagick->getImagePixelColor(49, 200)->getHsl(); |
|
199 | $whiteBarRight = $imagick->getImagePixelColor(151, 200)->getHsl(); |
|
200 | ||
201 | $imageTop = $imagick->getImagePixelColor(100, 176)->getHsl(); |
|
202 | $imageBottom = $imagick->getImagePixelColor(100, 224)->getHsl(); |
|
203 | $imageLeft = $imagick->getImagePixelColor(51, 200)->getHsl(); |
|
204 | $imageRight = $imagick->getImagePixelColor(149, 200)->getHsl(); |
|
205 | ||
206 | $this->assertGreaterThan(0.9, $whiteBarLeft['luminosity']); |
|
207 | $this->assertGreaterThan(0.9, $whiteBarRight['luminosity']); |
|
208 | ||
209 | $this->assertLessThan(0.1, $imageLeft['luminosity']); |
|
210 | $this->assertLessThan(0.1, $imageRight['luminosity']); |
|
211 | $this->assertLessThan(0.1, $imageTop['luminosity']); |
|
212 | $this->assertLessThan(0.1, $imageBottom['luminosity']); |
|
213 | } |
|
214 | ||
215 | /** |
|
216 | * @test |