rosell-dk / webp-convert

Convert jpeg/png to webp with PHP (if at all possible)
MIT License
576 stars 101 forks source link

Imagick should log version of the extension as well as version of the api #304

Closed rosell-dk closed 2 years ago

rosell-dk commented 2 years ago

Getting the module version is however not reliable.

There is phpversion('imagick');. However, it is not reliable, as it in some cases returns strange values such as "@PACKAGE_VERSION@" (https://github.com/php-imagine/Imagine/pull/628)

There is also \Imagick::IMAGICK_EXTVER. It has been around since 2.0.1 (https://pecl.php.net/package-info.php?package=imagick&version=2.0.1). However, it is not available on HHVM (https://github.com/dompdf/dompdf/pull/1504).

For logging, a mix of these two is good enough. Like this: $extVersion = (defined('\Imagick::IMAGICK_EXTVER') ? \Imagick::IMAGICK_EXTVER : phpversion('imagick'));

For logic, we should use feature detection such as !method_exists('\Imagick', 'clone')

See also https://github.com/dompdf/dompdf/issues/1296