Ticket #26823: multi_resize.patch
| File multi_resize.patch, 22.0 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/class-wp-image-editor-gd.php
140 140 * Resizes current image. 141 141 * Wraps _resize, since _resize returns a GD Resource. 142 142 * 143 * At minimum, either a height or width must be provided. 144 * If one of the two is set to null, the resize will 145 * maintain aspect ratio according to the provided dimension. 146 * 143 147 * @since 3.5.0 144 148 * @access public 145 149 * 146 * @param int $max_w147 * @param int $max_h150 * @param int|null $max_w Image Width 151 * @param int|null $max_h Image Height 148 152 * @param boolean $crop 149 153 * @return boolean|WP_Error 150 154 */ … … 205 209 $orig_size = $this->size; 206 210 207 211 foreach ( $sizes as $size => $size_data ) { 208 if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] )) )212 if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) 209 213 continue; 210 214 215 if ( ! isset( $size_data['width'] ) ) 216 $size_data['width'] = null; 217 if ( ! isset( $size_data['height'] ) ) 218 $size_data['height'] = null; 219 211 220 if ( ! isset( $size_data['crop'] ) ) 212 221 $size_data['crop'] = false; 213 222 -
src/wp-includes/class-wp-image-editor-imagick.php
211 211 /** 212 212 * Resizes current image. 213 213 * 214 * At minimum, either a height or width must be provided. 215 * If one of the two is set to null, the resize will 216 * maintain aspect ratio according to the provided dimension. 217 * 214 218 * @since 3.5.0 215 219 * @access public 216 220 * 217 * @param int $max_w218 * @param int $max_h221 * @param int|null $max_w Image Width 222 * @param int|null $max_h Image Height 219 223 * @param boolean $crop 220 224 * @return boolean|WP_Error 221 225 */ … … 255 259 * @param array $sizes { 256 260 * An array of image size arrays. Default sizes are 'small', 'medium', 'large'. 257 261 * 262 * Either a height or width must be provided. 263 * If one of the two is set to null, the resize will 264 * maintain aspect ratio according to the provided dimension. 265 * 258 266 * @type array $size { 259 * @type int $widthImage width.260 * @type int $heightImage height.267 * @type int ['width'] Optional. Image width. 268 * @type int ['height'] Optional. Image height. 261 269 * @type bool $crop Optional. Whether to crop the image. Default false. 262 270 * } 263 271 * } 264 * @return array An array of resized images metadata by size.272 * @return array An array of resized images' metadata by size. 265 273 */ 266 274 public function multi_resize( $sizes ) { 267 275 $metadata = array(); … … 272 280 if ( ! $this->image ) 273 281 $this->image = $orig_image->getImage(); 274 282 275 if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] )) )283 if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) 276 284 continue; 277 285 286 if ( ! isset( $size_data['width'] ) ) 287 $size_data['width'] = null; 288 if ( ! isset( $size_data['height'] ) ) 289 $size_data['height'] = null; 290 291 278 292 if ( ! isset( $size_data['crop'] ) ) 279 293 $size_data['crop'] = false; 280 294 -
tests/phpunit/tests/image/editor_gd.php
17 17 } 18 18 19 19 /** 20 * Helper function to check actual image dimensions on disk 21 * 22 * @access private 23 * 24 * @param string Image Filename 25 * @param int Width to Check 26 * @param int Height to Check 27 */ 28 private function check_image_dimensions( $filename, $width, $height ) { 29 # Now, verify real dimensions are as expected 30 $image = new WP_Image_Editor_GD( $filename ); 31 $image->load(); 32 33 $this->assertEquals( 34 array( 35 'width' => $width, 36 'height' => $height, 37 ), 38 $image->get_size() 39 ); 40 } 41 42 /** 20 43 * Check support for GD compatible mime types. 21 *22 44 */ 23 45 public function test_supports_mime_type() { 24 46 $gd_image_editor = new WP_Image_Editor_GD( null ); … … 30 52 31 53 /** 32 54 * Test resizing an image, not using crop 33 *34 55 */ 35 56 public function test_resize() { 57 $file = DIR_TESTDATA . '/images/waffles.jpg'; 36 58 37 $file = DIR_TESTDATA . '/images/gradient-square.jpg';38 39 59 $gd_image_editor = new WP_Image_Editor_GD( $file ); 40 60 $gd_image_editor->load(); 41 61 42 62 $gd_image_editor->resize( 100, 50 ); 43 63 44 $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $gd_image_editor->get_size() ); 64 $this->assertEquals( 65 array( 66 'width' => 75, 67 'height' => 50, 68 ), 69 $gd_image_editor->get_size() 70 ); 45 71 } 46 72 47 73 /** 48 * Test resizing an image including cropping 49 * 74 * Test multi_resize with single image resize and no crop 50 75 */ 76 public function test_single_multi_resize() { 77 $file = DIR_TESTDATA . '/images/waffles.jpg'; 78 79 $gd_image_editor = new WP_Image_Editor_GD( $file ); 80 $gd_image_editor->load(); 81 82 $sizes_array = array( 83 array( 84 'width' => 50, 85 'height' => 50, 86 ), 87 ); 88 89 $resized = $gd_image_editor->multi_resize( $sizes_array ); 90 91 # First, check to see if returned array is as expected 92 $expected_array = array( 93 array( 94 'file' => 'waffles-50x33.jpg', 95 'width' => 50, 96 'height' => 33, 97 'mime-type' => 'image/jpeg', 98 ), 99 ); 100 101 $this->assertEquals( $expected_array, $resized ); 102 103 // Now, verify real dimensions are as expected 104 $image_path = DIR_TESTDATA . '/images/'. $resized[0]['file']; 105 $this->check_image_dimensions( 106 $image_path, 107 $expected_array[0]['width'], 108 $expected_array[0]['height'] 109 ); 110 111 unlink( $image_path ); 112 } 113 114 /** 115 * Test multi_resize doesn't create an image as both H and W are null or 0 116 */ 117 public function test_multi_resize_does_not_create() { 118 $file = DIR_TESTDATA . '/images/waffles.jpg'; 119 120 $gd_image_editor = new WP_Image_Editor_GD( $file ); 121 $gd_image_editor->load(); 122 123 $pre_file_count = new FilesystemIterator(DIR_TESTDATA . '/images/', FilesystemIterator::SKIP_DOTS); 124 $sizes_array = array( 125 /** 126 * #1 - 127 * no output 128 */ 129 array( 130 'width' => 0, # Zero Value 131 'height' => 0, # Zero Value 132 ), 133 /** 134 * #2 - 135 * no output 136 */ 137 array( 138 'width' => 0, # Zero Value 139 'height' => 0, # Zero Value 140 'crop' => true, 141 ), 142 /** 143 * #3 - 144 * no output 145 */ 146 array( 147 'width' => 0, # Zero Value 148 'height' => 0, # Zero Value 149 ), 150 /** 151 * #4 - 152 * no output 153 */ 154 array( 155 'width' => 0, # Zero Value 156 'height' => 0, # Zero Value 157 'crop' => true, 158 ), 159 ); 160 161 162 // run function 163 $resized = $gd_image_editor->multi_resize( $sizes_array ); 164 165 // reurn an empty array 166 $this->assertEmpty($resized); 167 168 // recheck the target folder 169 $post_file_count = new FilesystemIterator(DIR_TESTDATA . '/images/', FilesystemIterator::SKIP_DOTS); 170 171 // make sure that a file hasn't been created 172 $this->assertEquals( iterator_count($pre_file_count), iterator_count($post_file_count)); 173 174 } 175 176 177 178 /** 179 * Test multi_resize with multiple sizes 180 * 181 * @ticket 26823 182 */ 183 public function test_multi_resize() { 184 $file = DIR_TESTDATA . '/images/waffles.jpg'; 185 186 $gd_image_editor = new WP_Image_Editor_GD( $file ); 187 $gd_image_editor->load(); 188 189 $sizes_array = array( 190 191 /** 192 * #0 - 10x10 resize, no cropping. 193 * By aspect, should be 10x6 output. 194 */ 195 array( 196 'width' => 10, 197 'height' => 10, 198 'crop' => false, 199 ), 200 201 /** 202 * #1 - 75x50 resize, with cropping. 203 * Output dimensions should be 75x50 204 */ 205 array( 206 'width' => 75, 207 'height' => 50, 208 'crop' => true, 209 ), 210 211 /** 212 * #2 - 20 pixel max height, no cropping. 213 * By aspect, should be 30x20 output. 214 */ 215 array( 216 'width' => 9999, # Arbitrary High Value 217 'height' => 20, 218 'crop' => false, 219 ), 220 221 /** 222 * #3 - 45 pixel max height, with cropping. 223 * By aspect, should be 45x400 output. 224 */ 225 array( 226 'width' => 45, 227 'height' => 9999, # Arbitrary High Value 228 'crop' => true, 229 ), 230 231 /** 232 * #4 - 50 pixel max width, no cropping. 233 * By aspect, should be 50x33 output. 234 */ 235 array( 236 'width' => 50, 237 ), 238 239 /** 240 * #5 - 55 pixel max width, no cropping, null height 241 * By aspect, should be 55x36 output. 242 */ 243 array( 244 'width' => 55, 245 'height' => null, 246 ), 247 248 /** 249 * #6 - 55 pixel max height, no cropping, no width specified. 250 * By aspect, should be 82x55 output. 251 */ 252 array( 253 'height' => 55, 254 ), 255 256 /** 257 * #7 - 60 pixel max height, no cropping, null width. 258 * By aspect, should be 90x60 output. 259 */ 260 array( 261 'width' => null, 262 'height' => 60, 263 ), 264 265 /** 266 * #8 - 70 pixel max height, no cropping, negative width. 267 * By aspect, should be 105x70 output. 268 */ 269 array( 270 'width' => -9999, # Arbitrary Negative Value 271 'height' => 70, 272 ), 273 274 /** 275 * #9 - 200 pixel max width, no cropping, negative height. 276 * By aspect, should be 200x133 output. 277 */ 278 array( 279 'width' => 200, 280 'height' => -9999, # Arbitrary Negative Value 281 ), 282 /** 283 * #9 - 200 pixel max width, no cropping, negative height. 284 * By aspect, should be 200x133 output. 285 */ 286 array( 287 'width' => 9999, # Arbitrary High Value 288 'height' => 9999, # Arbitrary High Value 289 ), 290 /** 291 * #9 - 200 pixel max width, no cropping, negative height. 292 * By aspect, should be 200x133 output. 293 */ 294 array( 295 'width' => 9999, # Arbitrary High Value 296 'height' => 9999, # Arbitrary High Value 297 'crop' => true, 298 ), 299 ); 300 301 302 // run function 303 $resized = $gd_image_editor->multi_resize( $sizes_array ); 304 305 $expected_array = array( 306 307 // #0 308 array( 309 'file' => 'waffles-10x6.jpg', 310 'width' => 10, 311 'height' => 6, 312 'mime-type' => 'image/jpeg', 313 ), 314 315 // #1 316 array( 317 'file' => 'waffles-75x50.jpg', 318 'width' => 75, 319 'height' => 50, 320 'mime-type' => 'image/jpeg', 321 ), 322 323 // #2 324 array( 325 'file' => 'waffles-30x20.jpg', 326 'width' => 30, 327 'height' => 20, 328 'mime-type' => 'image/jpeg', 329 ), 330 331 // #3 332 array( 333 'file' => 'waffles-45x400.jpg', 334 'width' => 45, 335 'height' => 400, 336 'mime-type' => 'image/jpeg', 337 ), 338 339 // #4 340 array( 341 'file' => 'waffles-50x33.jpg', 342 'width' => 50, 343 'height' => 33, 344 'mime-type' => 'image/jpeg', 345 ), 346 347 // #5 348 array( 349 'file' => 'waffles-55x36.jpg', 350 'width' => 55, 351 'height' => 36, 352 'mime-type' => 'image/jpeg', 353 ), 354 355 // #6 356 array( 357 'file' => 'waffles-82x55.jpg', 358 'width' => 82, 359 'height' => 55, 360 'mime-type' => 'image/jpeg', 361 ), 362 363 // #7 364 array( 365 'file' => 'waffles-90x60.jpg', 366 'width' => 90, 367 'height' => 60, 368 'mime-type' => 'image/jpeg', 369 ), 370 371 // #8 372 array( 373 'file' => 'waffles-105x70.jpg', 374 'width' => 105, 375 'height' => 70, 376 'mime-type' => 'image/jpeg', 377 ), 378 379 // #9 380 array( 381 'file' => 'waffles-200x133.jpg', 382 'width' => 200, 383 'height' => 133, 384 'mime-type' => 'image/jpeg', 385 ), 386 ); 387 388 $this->assertNotNull( $resized ); 389 $this->assertEquals( $expected_array, $resized ); 390 391 foreach( $resized as $key => $image_data ){ 392 $image_path = DIR_TESTDATA . '/images/' . $image_data['file']; 393 394 // Now, verify real dimensions are as expected 395 $this->check_image_dimensions( 396 $image_path, 397 $expected_array[$key]['width'], 398 $expected_array[$key]['height'] 399 ); 400 401 // Remove temporary file 402 unlink( $image_path ); 403 } 404 } 405 406 /** 407 * Test resizing an image with cropping 408 */ 51 409 public function test_resize_and_crop() { 52 53 410 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; 54 411 55 412 $gd_image_editor = new WP_Image_Editor_GD( $file ); … … 57 414 58 415 $gd_image_editor->resize( 100, 50, true ); 59 416 60 $this->assertEquals( array( 'width' => 100, 'height' => 50 ), $gd_image_editor->get_size() ); 417 $this->assertEquals( 418 array( 419 'width' => 100, 420 'height' => 50, 421 ), 422 $gd_image_editor->get_size() 423 ); 61 424 } 62 425 63 426 /** … … 64 427 * Test cropping an image 65 428 */ 66 429 public function test_crop() { 67 68 430 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; 69 431 70 432 $gd_image_editor = new WP_Image_Editor_GD( $file ); … … 72 434 73 435 $gd_image_editor->crop( 0, 0, 50, 50 ); 74 436 75 $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $gd_image_editor->get_size() ); 437 $this->assertEquals( 438 array( 439 'width' => 50, 440 'height' => 50, 441 ), 442 $gd_image_editor->get_size() 443 ); 76 444 77 445 } 78 446 … … 80 448 * Test rotating an image 180 deg 81 449 */ 82 450 public function test_rotate() { 83 84 451 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; 85 452 86 453 $gd_image_editor = new WP_Image_Editor_GD( $file ); … … 100 467 * Test flipping an image 101 468 */ 102 469 public function test_flip() { 103 104 470 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; 105 471 106 472 $gd_image_editor = new WP_Image_Editor_GD( $file ); … … 122 488 * @ticket 23039 123 489 */ 124 490 public function test_image_preserves_alpha_on_resize() { 125 126 491 $file = DIR_TESTDATA . '/images/transparent.png'; 127 492 128 493 $editor = wp_get_image_editor( $file ); … … 142 507 * @ticket 23039 143 508 */ 144 509 public function test_image_preserves_alpha() { 145 146 510 $file = DIR_TESTDATA . '/images/transparent.png'; 147 511 148 512 $editor = wp_get_image_editor( $file ); -
tests/phpunit/tests/image/editor_imagick.php
24 24 } 25 25 26 26 /** 27 * Helper function to check actual image dimensions on disk 28 * 29 * @access private 30 * 31 * @param string Image Filename 32 * @param int Width to Check 33 * @param int Height to Check 34 */ 35 private function check_image_dimensions( $filename, $width, $height ) { 36 $imagick_image_editor = new WP_Image_Editor_Imagick( $filename ); 37 $imagick_image_editor->load(); 38 39 $this->assertEquals( 40 array( 41 'width' => $width, 42 'height' => $height, 43 ), 44 $imagick_image_editor->get_size() 45 ); 46 } 47 48 /** 27 49 * Check support for Image Magick compatible mime types. 28 *29 50 */ 30 51 public function test_supports_mime_type() { 31 52 … … 38 59 39 60 /** 40 61 * Test resizing an image, not using crop 41 *42 62 */ 43 63 public function test_resize() { 64 $file = DIR_TESTDATA . '/images/waffles.jpg'; 44 65 45 $file = DIR_TESTDATA . '/images/gradient-square.jpg';46 47 66 $imagick_image_editor = new WP_Image_Editor_Imagick( $file ); 48 67 $imagick_image_editor->load(); 49 68 50 69 $imagick_image_editor->resize( 100, 50 ); 51 70 52 $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $imagick_image_editor->get_size() ); 71 $this->assertEquals( 72 array( 73 'width' => 75, 74 'height' => 50, 75 ), 76 $imagick_image_editor->get_size() 77 ); 53 78 } 54 79 55 80 /** 56 * Test resizing an image including cropping 57 * 81 * Test multi_resize with single image resize and no crop 58 82 */ 59 public function test_resize_and_crop() { 83 public function test_single_multi_resize() { 84 $file = DIR_TESTDATA . '/images/waffles.jpg'; 60 85 61 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; 86 $test_image = new WP_Image_Editor_Imagick( $file ); 87 $test_image->load(); 62 88 89 $sizes_array = array( 90 array( 91 'width' => 50, 92 'height' => 50, 93 ), 94 ); 95 96 $resized = $test_image->multi_resize( $sizes_array ); 97 98 # First, check to see if returned array is as expected 99 $expected_array = array( 100 array( 101 'file' => 'waffles-50x33.jpg', 102 'width' => 50, 103 'height' => 33, 104 'mime-type' => 'image/jpeg', 105 ), 106 ); 107 108 $this->assertEquals( $expected_array, $resized ); 109 110 // Now, verify real dimensions are as expected 111 $image_path = DIR_TESTDATA . '/images/'. $resized[0]['file']; 112 $this->check_image_dimensions( 113 $image_path, 114 $expected_array[0]['width'], 115 $expected_array[0]['height'] 116 ); 117 118 unlink( $image_path ); 119 } 120 121 /** 122 * Test multi_resize doesn't create an image as both H and W are null or 0 123 */ 124 public function test_multi_resize_does_not_create() { 125 $file = DIR_TESTDATA . '/images/waffles.jpg'; 126 127 $gd_image_editor = new WP_Image_Editor_Imagick( $file ); 128 $gd_image_editor->load(); 129 130 $pre_file_count = new FilesystemIterator(DIR_TESTDATA . '/images/', FilesystemIterator::SKIP_DOTS); 131 $sizes_array = array( 132 /** 133 * #1 - 134 * no output 135 */ 136 array( 137 'width' => 0, # Zero Value 138 'height' => 0, # Zero Value 139 ), 140 /** 141 * #2 - 142 * no output 143 */ 144 array( 145 'width' => 0, # Zero Value 146 'height' => 0, # Zero Value 147 'crop' => true, 148 ), 149 /** 150 * #3 - 151 * no output 152 */ 153 array( 154 'width' => 0, # Zero Value 155 'height' => 0, # Zero Value 156 ), 157 /** 158 * #4 - 159 * no output 160 */ 161 array( 162 'width' => 0, # Zero Value 163 'height' => 0, # Zero Value 164 'crop' => true, 165 ), 166 ); 167 168 169 // run function 170 $resized = $gd_image_editor->multi_resize( $sizes_array ); 171 172 // reurn an empty array 173 $this->assertEmpty($resized); 174 175 // recheck the target folder 176 $post_file_count = new FilesystemIterator(DIR_TESTDATA . '/images/', FilesystemIterator::SKIP_DOTS); 177 178 // make sure that a file hasn't been created 179 $this->assertEquals( iterator_count($pre_file_count), iterator_count($post_file_count)); 180 181 } 182 /** 183 * Test multi_resize with multiple sizes 184 * 185 * @ticket 26823 186 */ 187 public function test_multi_resize() { 188 $file = DIR_TESTDATA . '/images/waffles.jpg'; 189 63 190 $imagick_image_editor = new WP_Image_Editor_Imagick( $file ); 64 191 $imagick_image_editor->load(); 65 192 66 $ imagick_image_editor->resize( 100, 50, true );193 $sizes_array = array( 67 194 68 $this->assertEquals( array( 'width' => 100, 'height' => 50 ), $imagick_image_editor->get_size() ); 195 /** 196 * #0 - 10x10 resize, no cropping. 197 * By aspect, should be 10x6 output. 198 */ 199 array( 200 'width' => 10, 201 'height' => 10, 202 'crop' => false, 203 ), 204 205 /** 206 * #1 - 75x50 resize, with cropping. 207 * Output dimensions should be 75x50 208 */ 209 array( 210 'width' => 75, 211 'height' => 50, 212 'crop' => true, 213 ), 214 215 /** 216 * #2 - 20 pixel max height, no cropping. 217 * By aspect, should be 30x20 output. 218 */ 219 array( 220 'width' => 9999, # Arbitrary High Value 221 'height' => 20, 222 'crop' => false, 223 ), 224 225 /** 226 * #3 - 45 pixel max height, with cropping. 227 * By aspect, should be 45x400 output. 228 */ 229 array( 230 'width' => 45, 231 'height' => 9999, # Arbitrary High Value 232 'crop' => true, 233 ), 234 235 /** 236 * #4 - 50 pixel max width, no cropping. 237 * By aspect, should be 50x33 output. 238 */ 239 array( 240 'width' => 50, 241 ), 242 243 /** 244 * #5 - 55 pixel max width, no cropping, null height 245 * By aspect, should be 55x36 output. 246 */ 247 array( 248 'width' => 55, 249 'height' => null, 250 ), 251 252 /** 253 * #6 - 55 pixel max height, no cropping, no width specified. 254 * By aspect, should be 82x55 output. 255 */ 256 array( 257 'height' => 55, 258 ), 259 260 /** 261 * #7 - 60 pixel max height, no cropping, null width. 262 * By aspect, should be 90x60 output. 263 */ 264 array( 265 'width' => null, 266 'height' => 60, 267 ), 268 269 /** 270 * #8 - 70 pixel max height, no cropping, negative width. 271 * By aspect, should be 105x70 output. 272 */ 273 array( 274 'width' => -9999, # Arbitrary Negative Value 275 'height' => 70, 276 ), 277 278 /** 279 * #9 - 200 pixel max width, no cropping, negative height. 280 * By aspect, should be 200x133 output. 281 */ 282 array( 283 'width' => 200, 284 'height' => -9999, # Arbitrary Negative Value 285 ), 286 ); 287 288 $resized = $imagick_image_editor->multi_resize( $sizes_array ); 289 290 $expected_array = array( 291 292 // #0 293 array( 294 'file' => 'waffles-10x6.jpg', 295 'width' => 10, 296 'height' => 6, 297 'mime-type' => 'image/jpeg', 298 ), 299 300 // #1 301 array( 302 'file' => 'waffles-75x50.jpg', 303 'width' => 75, 304 'height' => 50, 305 'mime-type' => 'image/jpeg', 306 ), 307 308 // #2 309 array( 310 'file' => 'waffles-30x20.jpg', 311 'width' => 30, 312 'height' => 20, 313 'mime-type' => 'image/jpeg', 314 ), 315 316 // #3 317 array( 318 'file' => 'waffles-45x400.jpg', 319 'width' => 45, 320 'height' => 400, 321 'mime-type' => 'image/jpeg', 322 ), 323 324 // #4 325 array( 326 'file' => 'waffles-50x33.jpg', 327 'width' => 50, 328 'height' => 33, 329 'mime-type' => 'image/jpeg', 330 ), 331 332 // #5 333 array( 334 'file' => 'waffles-55x36.jpg', 335 'width' => 55, 336 'height' => 36, 337 'mime-type' => 'image/jpeg', 338 ), 339 340 // #6 341 array( 342 'file' => 'waffles-82x55.jpg', 343 'width' => 82, 344 'height' => 55, 345 'mime-type' => 'image/jpeg', 346 ), 347 348 // #7 349 array( 350 'file' => 'waffles-90x60.jpg', 351 'width' => 90, 352 'height' => 60, 353 'mime-type' => 'image/jpeg', 354 ), 355 356 // #8 357 array( 358 'file' => 'waffles-105x70.jpg', 359 'width' => 105, 360 'height' => 70, 361 'mime-type' => 'image/jpeg', 362 ), 363 364 // #9 365 array( 366 'file' => 'waffles-200x133.jpg', 367 'width' => 200, 368 'height' => 133, 369 'mime-type' => 'image/jpeg', 370 ), 371 ); 372 373 $this->assertNotNull( $resized ); 374 $this->assertEquals( $expected_array, $resized ); 375 376 foreach( $resized as $key => $image_data ){ 377 $image_path = DIR_TESTDATA . '/images/' . $image_data['file']; 378 379 // Now, verify real dimensions are as expected 380 $this->check_image_dimensions( 381 $image_path, 382 $expected_array[$key]['width'], 383 $expected_array[$key]['height'] 384 ); 385 386 // Remove temporary file 387 unlink( $image_path ); 388 } 69 389 } 70 390 71 391 /**