@@ 71-100 (lines=30) @@ | ||
68 | * @covers ::resize |
|
69 | * @covers ::resizeMulti |
|
70 | */ |
|
71 | public function resize_downsizeToMoreHorizontalAspect() |
|
72 | { |
|
73 | $source = new \Imagick('pattern:gray0'); |
|
74 | $source->scaleImage(100, 50); |
|
75 | ||
76 | $imagick = Image::resize($source, 40, 10); |
|
77 | ||
78 | //making sure source didnt resize |
|
79 | $this->assertSame(100, $source->getImageWidth()); |
|
80 | $this->assertSame(50, $source->getImageHeight()); |
|
81 | ||
82 | $this->assertSame(40, $imagick->getImageWidth()); |
|
83 | $this->assertSame(10, $imagick->getImageHeight()); |
|
84 | ||
85 | $whiteBarLeft = $imagick->getImagePixelColor(9, 4)->getHsl(); |
|
86 | $whiteBarRight = $imagick->getImagePixelColor(30, 4)->getHsl(); |
|
87 | ||
88 | $imageLeft = $imagick->getImagePixelColor(10, 4)->getHsl(); |
|
89 | $imageRight = $imagick->getImagePixelColor(29, 4)->getHsl(); |
|
90 | $imageTop = $imagick->getImagePixelColor(19, 0)->getHsl(); |
|
91 | $imageBottom = $imagick->getImagePixelColor(19, 9)->getHsl(); |
|
92 | ||
93 | $this->assertGreaterThan(0.9, $whiteBarLeft['luminosity']); |
|
94 | $this->assertGreaterThan(0.9, $whiteBarRight['luminosity']); |
|
95 | ||
96 | $this->assertLessThan(0.1, $imageLeft['luminosity']); |
|
97 | $this->assertLessThan(0.1, $imageRight['luminosity']); |
|
98 | $this->assertLessThan(0.1, $imageTop['luminosity']); |
|
99 | $this->assertLessThan(0.1, $imageBottom['luminosity']); |
|
100 | } |
|
101 | ||
102 | /** |
|
103 | * Upsize ratio 2.0 to 4.0 |
|
@@ 109-138 (lines=30) @@ | ||
106 | * @covers ::resize |
|
107 | * @covers ::resizeMulti |
|
108 | */ |
|
109 | public function resize_upsizeToMoreHorizontalAspectWithoutGrow() |
|
110 | { |
|
111 | $source = new \Imagick('pattern:gray0'); |
|
112 | $source->scaleImage(100, 50); |
|
113 | ||
114 | $imagick = Image::resize($source, 400, 100); |
|
115 | ||
116 | //making sure source didnt resize |
|
117 | $this->assertSame(100, $source->getImageWidth()); |
|
118 | $this->assertSame(50, $source->getImageHeight()); |
|
119 | ||
120 | $this->assertSame(400, $imagick->getImageWidth()); |
|
121 | $this->assertSame(100, $imagick->getImageHeight()); |
|
122 | ||
123 | $whiteBarLeft = $imagick->getImagePixelColor(99, 49)->getHsl(); |
|
124 | $whiteBarRight = $imagick->getImagePixelColor(300, 49)->getHsl(); |
|
125 | ||
126 | $imageTop = $imagick->getImagePixelColor(200, 26)->getHsl(); |
|
127 | $imageBottom = $imagick->getImagePixelColor(200, 74)->getHsl(); |
|
128 | $imageLeft = $imagick->getImagePixelColor(151, 50)->getHsl(); |
|
129 | $imageRight = $imagick->getImagePixelColor(249, 50)->getHsl(); |
|
130 | ||
131 | $this->assertGreaterThan(0.9, $whiteBarLeft['luminosity']); |
|
132 | $this->assertGreaterThan(0.9, $whiteBarRight['luminosity']); |
|
133 | ||
134 | $this->assertLessThan(0.1, $imageLeft['luminosity']); |
|
135 | $this->assertLessThan(0.1, $imageRight['luminosity']); |
|
136 | $this->assertLessThan(0.1, $imageTop['luminosity']); |
|
137 | $this->assertLessThan(0.1, $imageBottom['luminosity']); |
|
138 | } |
|
139 | ||
140 | /** |
|
141 | * Upsize ratio 2.0 to 4.0 |
|
@@ 147-176 (lines=30) @@ | ||
144 | * @covers ::resize |
|
145 | * @covers ::resizeMulti |
|
146 | */ |
|
147 | public function resize_upsizeToMoreHorizontalAspectWithGrow() |
|
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 |
|
@@ 185-214 (lines=30) @@ | ||
182 | * @covers ::resize |
|
183 | * @covers ::resizeMulti |
|
184 | */ |
|
185 | public function resize_upsizeToMoreVerticalAspect() |
|
186 | { |
|
187 | $source = new \Imagick('pattern:gray0'); |
|
188 | $source->scaleImage(100, 50); |
|
189 | ||
190 | $imagick = Image::resize($source, 200, 400); |
|
191 | ||
192 | //making sure source didnt resize |
|
193 | $this->assertSame(100, $source->getImageWidth()); |
|
194 | $this->assertSame(50, $source->getImageHeight()); |
|
195 | ||
196 | $this->assertSame(200, $imagick->getImageWidth()); |
|
197 | $this->assertSame(400, $imagick->getImageHeight()); |
|
198 | ||
199 | $whiteBarLeft = $imagick->getImagePixelColor(49, 200)->getHsl(); |
|
200 | $whiteBarRight = $imagick->getImagePixelColor(151, 200)->getHsl(); |
|
201 | ||
202 | $imageTop = $imagick->getImagePixelColor(100, 176)->getHsl(); |
|
203 | $imageBottom = $imagick->getImagePixelColor(100, 224)->getHsl(); |
|
204 | $imageLeft = $imagick->getImagePixelColor(51, 200)->getHsl(); |
|
205 | $imageRight = $imagick->getImagePixelColor(149, 200)->getHsl(); |
|
206 | ||
207 | $this->assertGreaterThan(0.9, $whiteBarLeft['luminosity']); |
|
208 | $this->assertGreaterThan(0.9, $whiteBarRight['luminosity']); |
|
209 | ||
210 | $this->assertLessThan(0.1, $imageLeft['luminosity']); |
|
211 | $this->assertLessThan(0.1, $imageRight['luminosity']); |
|
212 | $this->assertLessThan(0.1, $imageTop['luminosity']); |
|
213 | $this->assertLessThan(0.1, $imageBottom['luminosity']); |
|
214 | } |
|
215 | ||
216 | /** |
|
217 | * @test |