Skip to content

Conversation

@danielbachhuber
Copy link
Member

From #169

@danielbachhuber danielbachhuber marked this pull request as ready for review December 21, 2022 19:32
@danielbachhuber danielbachhuber requested a review from a team as a code owner December 21, 2022 19:32
@danielbachhuber
Copy link
Member Author

Test suite:

001 Scenario: Debug square image size part two # features/media-regenerate.feature:16
      Then STDOUT should be empty              # features/media-regenerate.feature:23
        $ file /tmp/wp-cli-test-cache/white-150-square.jpg
        /tmp/wp-cli-test-cache/white-150-square.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, progressive, precision 8, 150x150, components 1
        
        cwd: /tmp/wp-cli-test-run--63a36067645c77.65434519/
        run time: 0.0037679672241211
        exit status: 0 (Exception)

002 Scenario: Debug square image size part two # features/media-regenerate.feature:26
      Then STDOUT should be empty              # features/media-regenerate.feature:36
        $ wp post meta get 4 _wp_attachment_metadata
        array (
          'width' => 150,
          'height' => 150,
          'file' => 'white-150-square.jpg',
          'filesize' => 219,
          'sizes' => 
          array (
            'thumbnail' => 
            array (
              'file' => 'white-150-square-150x150.jpg',
              'width' => 150,
              'height' => 150,
              'mime-type' => 'image/jpeg',
              'filesize' => 251,
            ),
          ),
          'image_meta' => 
          array (
            'aperture' => '0',
            'credit' => '',
            'camera' => '',
            'caption' => '',
            'created_timestamp' => '0',
            'copyright' => '',
            'focal_length' => '0',
            'iso' => '0',
            'shutter_speed' => '0',
            'title' => '',
            'orientation' => '0',
            'keywords' => 
            array (
            ),
          ),
        )
        
        cwd: /tmp/wp-cli-test-run--63a36069dd4398.75544501/
        run time: 0.28598713874817
        exit status: 0 (Exception)

Locally:

001 Scenario: Debug square image size part two # features/media-regenerate.feature:16
      Then STDOUT should be empty              # features/media-regenerate.feature:23
        $ file /var/folders/6t/fzd50mwd57766jb0qdj2vl100000gn/T/wp-cli-test-cache/white-150-square.jpg
        /var/folders/6t/fzd50mwd57766jb0qdj2vl100000gn/T/wp-cli-test-cache/white-150-square.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, progressive, precision 8, 150x150, components 1

        cwd: /var/folders/6t/fzd50mwd57766jb0qdj2vl100000gn/T/wp-cli-test-run--63a3825ae67990.52853513/
        run time: 0.0071618556976318
        exit status: 0 (Exception)

002 Scenario: Debug square image size part two # features/media-regenerate.feature:26
      Then STDOUT should be empty              # features/media-regenerate.feature:36
        $ wp post meta get 4 _wp_attachment_metadata
        array (
          'width' => 150,
          'height' => 150,
          'file' => 'white-150-square.jpg',
          'filesize' => 219,
          'sizes' =>
          array (
          ),
          'image_meta' =>
          array (
            'aperture' => '0',
            'credit' => '',
            'camera' => '',
            'caption' => '',
            'created_timestamp' => '0',
            'copyright' => '',
            'focal_length' => '0',
            'iso' => '0',
            'shutter_speed' => '0',
            'title' => '',
            'orientation' => '0',
            'keywords' =>
            array (
            ),
          ),
        )

        cwd: /var/folders/6t/fzd50mwd57766jb0qdj2vl100000gn/T/wp-cli-test-run--63a3825f9a2cf9.40035046/
        run time: 0.21935796737671
        exit status: 0 (Exception)

@danielbachhuber
Copy link
Member Author

My guess is that something is wonky inside of image_size_dimensions() (https://github.com/WordPress/wordpress-develop/blob/0cb8475c0d07d23893b1d73d755eda5f12024585/src/wp-includes/media.php#L530-L657) or the resize() method of WP_Image_Editor_Imagick or WP_Iimage_Editor_GD (https://github.com/WordPress/wordpress-develop/blob/0cb8475c0d07d23893b1d73d755eda5f12024585/src/wp-includes/class-wp-image-editor-imagick.php#L270-L293). It's hard to say what it might be, though.

@danielbachhuber
Copy link
Member Author

Oh! The problem is definitely with WP_Image_Editor_Imagick.

As it turns out, I was running my previous tests with GD. I had installed ImageMagick, but hadn't yet enabled pecl install imagick.

Once I did so, the problem manifested right away:

$ wp site empty --uploads --yes && wp db reset --yes && wp core install
Success: The site at 'https://vanilla.test' was emptied.
Success: Database reset.
Success: WordPress installed successfully.
$ wp option update uploads_use_yearmonth_folders 0
Success: Updated 'uploads_use_yearmonth_folders' option.
$ wp media import white-150-square.jpg --title="My imported small attachment" --porcelain
4
$ ls wp-content/uploads
2022                         white-150-square-150x150.jpg white-150-square.jpg

@danielbachhuber
Copy link
Member Author

Debugging complete 🚢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants