Make WordPress Core

Changeset 58415


Ignore:
Timestamp:
06/14/2024 02:41:52 PM (6 months ago)
Author:
antpb
Message:

Media: Use version_compare() for Imagick version check when removing alpha.

Previously remove_pdf_alpha_channel() used Imagick::getVersion() to validate the environment is capable of handling alpha. This was the incorrect function to use to check the module version as it will only provide the ImageMagick API version. This patch adjusts to instead use phpversion() as this is the correct method to get the Imagick version needed to determine alpha compatibility. This fixes a number of host tests that have been correctly failing on subsets of environments. Serendipidously, sometimes the API version was high enough to avoid shining light on this problem.

Props swissspidy, joedolson, antpb.
Fixes #60798.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor-imagick.php

    r57934 r58415  
    776776     */
    777777    protected function remove_pdf_alpha_channel() {
    778         $version = Imagick::getVersion();
    779778        // Remove alpha channel if possible to avoid black backgrounds for Ghostscript >= 9.14. RemoveAlphaChannel added in ImageMagick 6.7.5.
    780         if ( $version['versionNumber'] >= 0x675 ) {
     779        if ( version_compare( phpversion( 'imagick' ), '9.14', '>=' ) ) {
    781780            try {
    782781                // Imagick::ALPHACHANNEL_REMOVE mapped to RemoveAlphaChannel in PHP imagick 3.2.0b2.
Note: See TracChangeset for help on using the changeset viewer.