Make WordPress Core

Ticket #26823: 26823.2.diff

File 26823.2.diff, 20.7 KB (added by kirasong, 11 years ago)

Previous Patch, plus setting null rather than 0 for missing values, Consolidated Tests, and updated documentation

  • src/wp-includes/class-wp-image-editor-gd.php

    diff --git src/wp-includes/class-wp-image-editor-gd.php src/wp-includes/class-wp-image-editor-gd.php
    index fdd5586..0b13ad0 100644
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    140140         * Resizes current image.
    141141         * Wraps _resize, since _resize returns a GD Resource.
    142142         *
     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         *
    143147         * @since 3.5.0
    144148         * @access public
    145149         *
    146          * @param int $max_w
    147          * @param int $max_h
     150         * @param int|null $max_w Image Width
     151         * @param int|null $max_h Image Height
    148152         * @param boolean $crop
    149153         * @return boolean|WP_Error
    150154         */
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    192196         * @param array $sizes {
    193197         *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
    194198         *
     199         *     Either a height or width must be provided.
     200         *     If one of the two is set to null, the resize will
     201         *     maintain aspect ratio according to the provided dimension.
     202         *
    195203         *     @type array $size {
    196          *         @type int  $width Image width.
    197          *         @type int  $height Image height.
    198          *         @type bool $crop   Optional. Whether to crop the image. Default false.
     204         *         @type int  ['width']  Optional. Image width.
     205         *         @type int  ['height'] Optional. Image height.
     206         *         @type bool ['crop']   Optional. Whether to crop the image. Default false.
    199207         *     }
    200208         * }
    201          * @return array An array of resized images metadata by size.
     209         * @return array An array of resized images' metadata by size.
    202210         */
    203211        public function multi_resize( $sizes ) {
    204212                $metadata = array();
    205213                $orig_size = $this->size;
    206214
    207215                foreach ( $sizes as $size => $size_data ) {
    208                         if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
     216                        if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
    209217                                continue;
     218                        }
    210219
    211                         if ( ! isset( $size_data['crop'] ) )
     220                        if ( ! isset( $size_data['width'] ) ) {
     221                                $size_data['width'] = null;
     222                        }
     223                        if ( ! isset( $size_data['height'] ) ) {
     224                                $size_data['height'] = null;
     225                        }
     226
     227                        if ( ! isset( $size_data['crop'] ) ) {
    212228                                $size_data['crop'] = false;
     229                        }
    213230
    214231                        $image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
    215232
  • src/wp-includes/class-wp-image-editor-imagick.php

    diff --git src/wp-includes/class-wp-image-editor-imagick.php src/wp-includes/class-wp-image-editor-imagick.php
    index f3c9451..be98447 100644
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    211211        /**
    212212         * Resizes current image.
    213213         *
     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         *
    214218         * @since 3.5.0
    215219         * @access public
    216220         *
    217          * @param int $max_w
    218          * @param int $max_h
     221         * @param int|null $max_w Image Width
     222         * @param int|null $max_h Image Height
    219223         * @param boolean $crop
    220224         * @return boolean|WP_Error
    221225         */
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    255259         * @param array $sizes {
    256260         *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
    257261         *
     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         *
    258266         *     @type array $size {
    259          *         @type int  $width Image width.
    260          *         @type int  $height Image height.
     267         *         @type int  ['width']  Optional. Image width.
     268         *         @type int  ['height'] Optional. Image height.
    261269         *         @type bool $crop   Optional. Whether to crop the image. Default false.
    262270         *     }
    263271         * }
    264          * @return array An array of resized images metadata by size.
     272         * @return array An array of resized images' metadata by size.
    265273         */
    266274        public function multi_resize( $sizes ) {
    267275                $metadata = array();
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    272280                        if ( ! $this->image )
    273281                                $this->image = $orig_image->getImage();
    274282
    275                         if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
     283                        if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
    276284                                continue;
     285                        }
    277286
    278                         if ( ! isset( $size_data['crop'] ) )
     287                        if ( ! isset( $size_data['width'] ) ) {
     288                                $size_data['width'] = null;
     289                        }
     290                        if ( ! isset( $size_data['height'] ) ) {
     291                                $size_data['height'] = null;
     292                        }
     293
     294                        if ( ! isset( $size_data['crop'] ) ) {
    279295                                $size_data['crop'] = false;
     296                        }
    280297
    281298                        $resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
    282299
  • tests/phpunit/tests/image/editor_gd.php

    diff --git tests/phpunit/tests/image/editor_gd.php tests/phpunit/tests/image/editor_gd.php
    index f5fdd99..c699012 100644
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    1717        }
    1818
    1919        /**
     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        /**
    2043         * Check support for GD compatible mime types.
    21          *
    2244         */
    2345        public function test_supports_mime_type() {
    2446                $gd_image_editor = new WP_Image_Editor_GD( null );
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    3052
    3153        /**
    3254         * Test resizing an image, not using crop
    33          *
    3455         */
    3556        public function test_resize() {
    36 
    37                 $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     57                $file = DIR_TESTDATA . '/images/waffles.jpg';
    3858
    3959                $gd_image_editor = new WP_Image_Editor_GD( $file );
    4060                $gd_image_editor->load();
    4161
    4262                $gd_image_editor->resize( 100, 50 );
    4363
    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                );
    4571        }
    4672
    4773        /**
    48          * Test resizing an image including cropping
    49          *
     74         * Test multi_resize with single image resize and no crop
    5075         */
    51         public function test_resize_and_crop() {
     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                // Now, verify real dimensions are as expected
     102                $image_path = DIR_TESTDATA . '/images/'. $resized[0]['file'];
     103                $this->check_image_dimensions(
     104                        $image_path,
     105                        $expected_array[0]['width'],
     106                        $expected_array[0]['height']
     107                );
     108
     109                unlink( $image_path );
     110        }
     111
    52112
     113        /**
     114         * Test multi_resize with multiple sizes
     115         *
     116         * @ticket 26823
     117         */
     118        public function test_multi_resize() {
     119                $file = DIR_TESTDATA . '/images/waffles.jpg';
     120
     121                $gd_image_editor = new WP_Image_Editor_GD( $file );
     122                $gd_image_editor->load();
     123
     124                $sizes_array = array(
     125
     126                        /**
     127                         * #0 - 10x10 resize, no cropping.
     128                         * By aspect, should be 10x6 output.
     129                         */
     130                        array(
     131                                'width'  => 10,
     132                                'height' => 10,
     133                                'crop'   => false,
     134                        ),
     135
     136                        /**
     137                         * #1 - 75x50 resize, with cropping.
     138                         * Output dimensions should be 75x50
     139                         */
     140                        array(
     141                                'width'  => 75,
     142                                'height' => 50,
     143                                'crop'   => true,
     144                        ),
     145
     146                        /**
     147                         * #2 - 20 pixel max height, no cropping.
     148                         * By aspect, should be 30x20 output.
     149                         */
     150                        array(
     151                                'width'  => 9999, # Arbitrary High Value
     152                                'height' => 20,
     153                                'crop'   => false,
     154                        ),
     155
     156                        /**
     157                         * #3 - 45 pixel max height, with cropping.
     158                         * By aspect, should be 45x400 output.
     159                         */
     160                        array(
     161                                'width'  => 45,
     162                                'height' => 9999, # Arbitrary High Value
     163                                'crop'   => true,
     164                        ),
     165
     166                        /**
     167                         * #4 - 50 pixel max width, no cropping.
     168                         * By aspect, should be 50x33 output.
     169                         */
     170                        array(
     171                                'width' => 50,
     172                        ),
     173
     174                        /**
     175                         * #5 - 55 pixel max width, no cropping, null height
     176                         * By aspect, should be 55x36 output.
     177                         */
     178                        array(
     179                                'width'  => 55,
     180                                'height' => null,
     181                        ),
     182
     183                        /**
     184                         * #6 - 55 pixel max height, no cropping, no width specified.
     185                         * By aspect, should be 82x55 output.
     186                         */
     187                        array(
     188                                'height' => 55,
     189                        ),
     190
     191                        /**
     192                         * #7 - 60 pixel max height, no cropping, null width.
     193                         * By aspect, should be 90x60 output.
     194                         */
     195                        array(
     196                                'width'  => null,
     197                                'height' => 60,
     198                        ),
     199
     200                        /**
     201                         * #8 - 70 pixel max height, no cropping, negative width.
     202                         * By aspect, should be 105x70 output.
     203                         */
     204                        array(
     205                                'width'  => -9999, # Arbitrary Negative Value
     206                                'height' => 70,
     207                        ),
     208
     209                        /**
     210                         * #9 - 200 pixel max width, no cropping, negative height.
     211                         * By aspect, should be 200x133 output.
     212                         */
     213                        array(
     214                                'width'  => 200,
     215                                'height' => -9999, # Arbitrary Negative Value
     216                        ),
     217                );
     218
     219                $resized = $gd_image_editor->multi_resize( $sizes_array );
     220
     221                $expected_array = array(
     222
     223                        // #0
     224                        array(
     225                                'file'      => 'waffles-10x6.jpg',
     226                                'width'     => 10,
     227                                'height'    => 6,
     228                                'mime-type' => 'image/jpeg',
     229                        ),
     230
     231                        // #1
     232                        array(
     233                                'file'      => 'waffles-75x50.jpg',
     234                                'width'     => 75,
     235                                'height'    => 50,
     236                                'mime-type' => 'image/jpeg',
     237                        ),
     238
     239                        // #2
     240                        array(
     241                                'file'      => 'waffles-30x20.jpg',
     242                                'width'     => 30,
     243                                'height'    => 20,
     244                                'mime-type' => 'image/jpeg',
     245                        ),
     246
     247                        // #3
     248                        array(
     249                                'file'      => 'waffles-45x400.jpg',
     250                                'width'     => 45,
     251                                'height'    => 400,
     252                                'mime-type' => 'image/jpeg',
     253                        ),
     254
     255                        // #4
     256                        array(
     257                                'file'      => 'waffles-50x33.jpg',
     258                                'width'     => 50,
     259                                'height'    => 33,
     260                                'mime-type' => 'image/jpeg',
     261                        ),
     262
     263                        // #5
     264                        array(
     265                                'file'      => 'waffles-55x36.jpg',
     266                                'width'     => 55,
     267                                'height'    => 36,
     268                                'mime-type' => 'image/jpeg',
     269                        ),
     270
     271                        // #6
     272                        array(
     273                                'file'      => 'waffles-82x55.jpg',
     274                                'width'     => 82,
     275                                'height'    => 55,
     276                                'mime-type' => 'image/jpeg',
     277                        ),
     278
     279                        // #7
     280                        array(
     281                                'file'      => 'waffles-90x60.jpg',
     282                                'width'     => 90,
     283                                'height'    => 60,
     284                                'mime-type' => 'image/jpeg',
     285                        ),
     286
     287                        // #8
     288                        array(
     289                                'file'      => 'waffles-105x70.jpg',
     290                                'width'     => 105,
     291                                'height'    => 70,
     292                                'mime-type' => 'image/jpeg',
     293                        ),
     294
     295                        // #9
     296                        array(
     297                                'file'      => 'waffles-200x133.jpg',
     298                                'width'     => 200,
     299                                'height'    => 133,
     300                                'mime-type' => 'image/jpeg',
     301                        ),
     302                );
     303
     304                $this->assertNotNull( $resized );
     305                $this->assertEquals( $expected_array, $resized );
     306
     307                foreach( $resized as $key => $image_data ){
     308                        $image_path = DIR_TESTDATA . '/images/' . $image_data['file'];
     309
     310                        // Now, verify real dimensions are as expected
     311                        $this->check_image_dimensions(
     312                                $image_path,
     313                                $expected_array[$key]['width'],
     314                                $expected_array[$key]['height']
     315                        );
     316
     317                        // Remove temporary file
     318                        unlink( $image_path );
     319                }
     320        }
     321
     322        /**
     323         * Test resizing an image with cropping
     324         */
     325        public function test_resize_and_crop() {
    53326                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
    54327
    55328                $gd_image_editor = new WP_Image_Editor_GD( $file );
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    57330
    58331                $gd_image_editor->resize( 100, 50, true );
    59332
    60                 $this->assertEquals( array( 'width' => 100, 'height' => 50 ), $gd_image_editor->get_size() );
     333                $this->assertEquals(
     334                        array(
     335                                'width'  => 100,
     336                                'height' => 50,
     337                        ),
     338                        $gd_image_editor->get_size()
     339                );
    61340        }
    62341
    63342        /**
    64343         * Test cropping an image
    65344         */
    66345        public function test_crop() {
    67 
    68346                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
    69347
    70348                $gd_image_editor = new WP_Image_Editor_GD( $file );
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    72350
    73351                $gd_image_editor->crop( 0, 0, 50, 50 );
    74352
    75                 $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $gd_image_editor->get_size() );
     353                $this->assertEquals(
     354                        array(
     355                                'width' => 50,
     356                                'height' => 50,
     357                        ),
     358                        $gd_image_editor->get_size()
     359                );
    76360
    77361        }
    78362
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    80364         * Test rotating an image 180 deg
    81365         */
    82366        public function test_rotate() {
    83 
    84367                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
    85368
    86369                $gd_image_editor = new WP_Image_Editor_GD( $file );
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    100383         * Test flipping an image
    101384         */
    102385        public function test_flip() {
    103 
    104386                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
    105387
    106388                $gd_image_editor = new WP_Image_Editor_GD( $file );
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    122404         * @ticket 23039
    123405         */
    124406        public function test_image_preserves_alpha_on_resize() {
    125 
    126407                $file = DIR_TESTDATA . '/images/transparent.png';
    127408
    128409                $editor = wp_get_image_editor( $file );
    class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { 
    142423         * @ticket 23039
    143424         */
    144425        public function test_image_preserves_alpha() {
    145 
    146426                $file = DIR_TESTDATA . '/images/transparent.png';
    147427
    148428                $editor = wp_get_image_editor( $file );
  • tests/phpunit/tests/image/editor_imagick.php

    diff --git tests/phpunit/tests/image/editor_imagick.php tests/phpunit/tests/image/editor_imagick.php
    index 1e43298..7060f44 100644
    class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { 
    2424        }
    2525
    2626        /**
     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        /**
    2749         * Check support for Image Magick compatible mime types.
    28          *
    2950         */
    3051        public function test_supports_mime_type() {
    3152
    class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { 
    3859
    3960        /**
    4061         * Test resizing an image, not using crop
    41          *
    4262         */
    4363        public function test_resize() {
    44 
    45                 $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     64                $file = DIR_TESTDATA . '/images/waffles.jpg';
    4665
    4766                $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
    4867                $imagick_image_editor->load();
    4968
    5069                $imagick_image_editor->resize( 100, 50 );
    5170
    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                );
    5378        }
    5479
    5580        /**
    56          * Test resizing an image including cropping
    57          *
     81         * Test multi_resize with single image resize and no crop
    5882         */
    59         public function test_resize_and_crop() {
     83        public function test_single_multi_resize() {
     84                $file = DIR_TESTDATA . '/images/waffles.jpg';
     85
     86                $test_image = new WP_Image_Editor_Imagick( $file );
     87                $test_image->load();
     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        }
    60120
    61                 $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     121        /**
     122         * Test multi_resize with multiple sizes
     123         *
     124         * @ticket 26823
     125         */
     126        public function test_multi_resize() {
     127                $file = DIR_TESTDATA . '/images/waffles.jpg';
    62128
    63129                $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
    64130                $imagick_image_editor->load();
    65131
    66                 $imagick_image_editor->resize( 100, 50, true );
    67 
    68                 $this->assertEquals( array( 'width' => 100, 'height' => 50 ), $imagick_image_editor->get_size() );
     132                $sizes_array = array(
     133
     134                        /**
     135                         * #0 - 10x10 resize, no cropping.
     136                         * By aspect, should be 10x6 output.
     137                         */
     138                        array(
     139                                'width'  => 10,
     140                                'height' => 10,
     141                                'crop'   => false,
     142                        ),
     143
     144                        /**
     145                         * #1 - 75x50 resize, with cropping.
     146                         * Output dimensions should be 75x50
     147                         */
     148                        array(
     149                                'width'  => 75,
     150                                'height' => 50,
     151                                'crop'   => true,
     152                        ),
     153
     154                        /**
     155                         * #2 - 20 pixel max height, no cropping.
     156                         * By aspect, should be 30x20 output.
     157                         */
     158                        array(
     159                                'width'  => 9999, # Arbitrary High Value
     160                                'height' => 20,
     161                                'crop'   => false,
     162                        ),
     163
     164                        /**
     165                         * #3 - 45 pixel max height, with cropping.
     166                         * By aspect, should be 45x400 output.
     167                         */
     168                        array(
     169                                'width'  => 45,
     170                                'height' => 9999, # Arbitrary High Value
     171                                'crop'   => true,
     172                        ),
     173
     174                        /**
     175                         * #4 - 50 pixel max width, no cropping.
     176                         * By aspect, should be 50x33 output.
     177                         */
     178                        array(
     179                                'width' => 50,
     180                        ),
     181
     182                        /**
     183                         * #5 - 55 pixel max width, no cropping, null height
     184                         * By aspect, should be 55x36 output.
     185                         */
     186                        array(
     187                                'width'  => 55,
     188                                'height' => null,
     189                        ),
     190
     191                        /**
     192                         * #6 - 55 pixel max height, no cropping, no width specified.
     193                         * By aspect, should be 82x55 output.
     194                         */
     195                        array(
     196                                'height' => 55,
     197                        ),
     198
     199                        /**
     200                         * #7 - 60 pixel max height, no cropping, null width.
     201                         * By aspect, should be 90x60 output.
     202                         */
     203                        array(
     204                                'width'  => null,
     205                                'height' => 60,
     206                        ),
     207
     208                        /**
     209                         * #8 - 70 pixel max height, no cropping, negative width.
     210                         * By aspect, should be 105x70 output.
     211                         */
     212                        array(
     213                                'width'  => -9999, # Arbitrary Negative Value
     214                                'height' => 70,
     215                        ),
     216
     217                        /**
     218                         * #9 - 200 pixel max width, no cropping, negative height.
     219                         * By aspect, should be 200x133 output.
     220                         */
     221                        array(
     222                                'width'  => 200,
     223                                'height' => -9999, # Arbitrary Negative Value
     224                        ),
     225                );
     226
     227                $resized = $imagick_image_editor->multi_resize( $sizes_array );
     228
     229                $expected_array = array(
     230
     231                        // #0
     232                        array(
     233                                'file'      => 'waffles-10x6.jpg',
     234                                'width'     => 10,
     235                                'height'    => 6,
     236                                'mime-type' => 'image/jpeg',
     237                        ),
     238
     239                        // #1
     240                        array(
     241                                'file'      => 'waffles-75x50.jpg',
     242                                'width'     => 75,
     243                                'height'    => 50,
     244                                'mime-type' => 'image/jpeg',
     245                        ),
     246
     247                        // #2
     248                        array(
     249                                'file'      => 'waffles-30x20.jpg',
     250                                'width'     => 30,
     251                                'height'    => 20,
     252                                'mime-type' => 'image/jpeg',
     253                        ),
     254
     255                        // #3
     256                        array(
     257                                'file'      => 'waffles-45x400.jpg',
     258                                'width'     => 45,
     259                                'height'    => 400,
     260                                'mime-type' => 'image/jpeg',
     261                        ),
     262
     263                        // #4
     264                        array(
     265                                'file'      => 'waffles-50x33.jpg',
     266                                'width'     => 50,
     267                                'height'    => 33,
     268                                'mime-type' => 'image/jpeg',
     269                        ),
     270
     271                        // #5
     272                        array(
     273                                'file'      => 'waffles-55x36.jpg',
     274                                'width'     => 55,
     275                                'height'    => 36,
     276                                'mime-type' => 'image/jpeg',
     277                        ),
     278
     279                        // #6
     280                        array(
     281                                'file'      => 'waffles-82x55.jpg',
     282                                'width'     => 82,
     283                                'height'    => 55,
     284                                'mime-type' => 'image/jpeg',
     285                        ),
     286
     287                        // #7
     288                        array(
     289                                'file'      => 'waffles-90x60.jpg',
     290                                'width'     => 90,
     291                                'height'    => 60,
     292                                'mime-type' => 'image/jpeg',
     293                        ),
     294
     295                        // #8
     296                        array(
     297                                'file'      => 'waffles-105x70.jpg',
     298                                'width'     => 105,
     299                                'height'    => 70,
     300                                'mime-type' => 'image/jpeg',
     301                        ),
     302
     303                        // #9
     304                        array(
     305                                'file'      => 'waffles-200x133.jpg',
     306                                'width'     => 200,
     307                                'height'    => 133,
     308                                'mime-type' => 'image/jpeg',
     309                        ),
     310                );
     311
     312                $this->assertNotNull( $resized );
     313                $this->assertEquals( $expected_array, $resized );
     314
     315                foreach( $resized as $key => $image_data ){
     316                        $image_path = DIR_TESTDATA . '/images/' . $image_data['file'];
     317
     318                        // Now, verify real dimensions are as expected
     319                        $this->check_image_dimensions(
     320                                $image_path,
     321                                $expected_array[$key]['width'],
     322                                $expected_array[$key]['height']
     323                        );
     324
     325                        // Remove temporary file
     326                        unlink( $image_path );
     327                }
    69328        }
    70329
    71330        /**