[wp-trac] [WordPress Trac] #57370: WP_Image_Editor_Imagick creates unexpected 'thumbnail' image size when original image is 150x150

WordPress Trac noreply at wordpress.org
Wed Dec 21 23:23:53 UTC 2022


#57370: WP_Image_Editor_Imagick creates unexpected 'thumbnail' image size when
original image is 150x150
-----------------------------+-----------------------------
 Reporter:  danielbachhuber  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Media            |    Version:
 Severity:  normal           |   Keywords:  needs-patch
  Focuses:                   |
-----------------------------+-----------------------------
 Discovered with https://github.com/wp-cli/media-command/pull/173

 If you have `brew install imagemagick` and `pecl install imagick`, the
 issue reproduces with pretty easily with WP-CLI:

 {{{
 $ wp site empty --uploads --yes && wp db reset --yes && wp core install &&
 wp option update uploads_use_yearmonth_folders 0
 Success: The site at 'https://vanilla.test' was emptied.
 Success: Database reset.
 Success: WordPress installed successfully.
 Success: Updated 'uploads_use_yearmonth_folders' option.
 $ wget http://wp-cli.org/behat-data/white-150-square.jpg
 $ wp media import white-150-square.jpg --title="My imported small
 attachment"
 Imported file 'white-150-square.jpg' as attachment ID 4.
 Success: Imported 1 of 1 items.
 $ ls wp-content/uploads
 white-150-square-150x150.jpg   white-150-square.jpg
 }}}

 Only `white-150-square.jpg` should be present, not `white-150-square-
 150x150.jpg`.

 The underlying problem is that `WP_Image_Editor_Imagick->resize()` returns
 `true` (https://github.com/WordPress/wordpress-
 develop/blob/e993bc5f739af0ac589049c1f102788f57a1983d/src/wp-includes
 /class-wp-image-editor-imagick.php#L270-L273), and then `make_subsize()`
 proceeds to save a new image anyway (https://github.com/WordPress
 /wordpress-develop/blob/e993bc5f739af0ac589049c1f102788f57a1983d/src/wp-
 includes/class-wp-image-editor-imagick.php#L506-L516)

 The behavior doesn't happen with `WP_Image_Editor_GD` because it has some
 `is_gd_image()` check (https://github.com/WordPress/wordpress-
 develop/blob/e993bc5f739af0ac589049c1f102788f57a1983d/src/wp-includes
 /class-wp-image-editor-gd.php#L178-L185)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57370>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list