JamesHeinrich / phpThumb

phpThumb() - The PHP thumbnail generator
Other
315 stars 98 forks source link

phpThumb detects wrong ImageMagick version #157

Closed alexmla closed 4 years ago

alexmla commented 4 years ago

I had ImageMagick 6.9.8-3 installed but recently compiled a newer version 6.9.11-24 with HEIC support. Imagick is updated and works and phpinfo shows the correct versions installed. When I run a convert --version I get:

Version: ImageMagick 6.9.11-24 Q16 x86_64 2020-07-30 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): freetype heic jng jpeg ltdl png tiff webp wmf xml zlib

Which is the new version. However, when I run the configuration demo, I still get the old version reported. Also HEIC images seem not to be supported, so for whatever reason phpThumb is still using the old version. Any way to rectify this?

ImageMagick version: | /opt/bitnami/common/bin/convert [1] [1] [1] [1] [1]convert6.9.8-3 Q16

I also get:

sh: 1: ./identify: not found

But it is definitely there when I run identify from the terminal.

Thanks!

JamesHeinrich commented 4 years ago

Apparently you have multiple versions of ImageMagick installed. phpThumb runs which convert to find/guess the installation location, but if it guesses wrong just set $PHPTHUMB_CONFIG['imagemagick_path'] in phpThumb.config.php

alexmla commented 4 years ago

Thanks, Unfortunately, I already have that set "/opt/bitnami/common/bin/convert" which is where "which" returns the path. That also gives me the correct version when I do convert --version.

 /opt/bitnami/common/bin/convert --version
Version: ImageMagick 6.9.11-24 Q16 x86_64 2020-07-30 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): freetype heic jng jpeg ltdl png tiff webp wmf xml zlib

phpThumb still seems not to use the correct version though.

JamesHeinrich commented 4 years ago

You'll have to turn on debug mode and take through the output at the section where it's selecting the ImageMagick location to use, there may be some clues as to what's happening there.

alexmla commented 4 years ago

Thanks,

even though I point at the correct path, it gets the wrong version. If I run the convert --version manually (at the set path), then I get the latest version, but here it does not. This is the debug section output:

$this->config_prefer_imagemagick            = TRUE
$this->config_imagemagick_path              = string(31)  "/opt/bitnami/common/bin/convert"
$this->ImageMagickWhichConvert()            = /opt/bitnami/common/bin/convert
[actual ImageMagick path used]              = string(31)  "/opt/bitnami/common/bin/convert"
file_exists([actual ImageMagick path used]) = TRUE
ImageMagickVersion(false)                   = 6.9.8-3 Q16
ImageMagickVersion(true)                    = Version: ImageMagick 6.9.8-3 Q16 x86_64 2019-08-30 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl png tiff wmf xml zlib
further down:
  * setParameter(config_prefer_imagemagick, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_imagemagick_use_thumbnail, TRUE) in file "phpThumb.php" on line 160
  * setParameter(config_imagemagick_path, string(31)  "/opt/bitnami/common/bin/convert") in file "phpThumb.php" on line 160

and again:

  * ImageMagickSwitchAvailable(density) = 1 in file "phpthumb.class.php" on line 1571
  * getimagesize(/opt/bitnami/apps/d_b/htdocs/img/02691578.jpeg) returned [w=783;h=781;f=2] in file "phpthumb.class.php" on line 1745
  * source dimensions set to 783x781 in file "phpthumb.class.php" on line 1748
  * SetOrientationDependantWidthHeight() starting with "783"x"781" in file "phpthumb.class.php" on line 3368
  * SetOrientationDependantWidthHeight() setting w="240", h="210" in file "phpthumb.class.php" on line 3384
  * ImageMagickSwitchAvailable(repage) = 1 in file "phpthumb.class.php" on line 1571
  * Remaining $this->fltr after ImageMagick: (array(0) { } ) in file "phpthumb.class.php" on line 2296
  * ImageMagickSwitchAvailable(quality;interlace) = 1 in file "phpthumb.class.php" on line 1568
  * ImageMagick called as (convert '/opt/bitnami/apps/d_b/htdocs/img/02691578.jpeg[0]' -flatten -density '150' -background '#FFFFFF' -thumbnail "240x210^" -gravity center -crop '240x210+0+0' +repage -quality '75' -interlace line  jpeg:'/opt/bitnami/apps/d_b/htdocs/php/cache/pThumbqMoLpe' 2>&1) in file "phpthumb.class.php" on line 2314
  * getimagesize(/opt/bitnami/apps/d_b/htdocs/php/cache/pThumbqMoLpe) returned [w=240;h=210;f=2] in file "phpthumb.class.php" on line 2331
  * ImageMagickThumbnailToGD::imagecreatefromjpeg() succeeded, $this->gdimg_source is now (240x210) in file "phpthumb.class.php" on line 2337
  * ImageMagickThumbnailToGD() returning $this->IMresizedData (6097 bytes) in file "phpthumb.class.php" on line 2338
JamesHeinrich commented 4 years ago

I have no explanation as to why that would happen or how that's even possible, for a single absolute filename (/opt/bitnami/common/bin/convert) to appear as two different versions. If you manage to drill down and find out what's happening I would be interested to know what you uncover.

alexmla commented 4 years ago

I am assuming there must be a bug somewhere. When I checked the ENV, it clearly shows that the latest ImageMagic I compiled is in use. phpinfo claims the same.

##### IMAGEMAGICK ENV #####
MAGICK_CONFIGURE_PATH="/opt/bitnami/common/lib/ImageMagick-6.9.11/config-Q16:/opt/bitnami/common/"
MAGICK_CODER_MODULE_PATH="/opt/bitnami/common/lib/ImageMagick-6.9.11/modules-Q16/coders"
mertasan commented 4 years ago

I was having the same problem. After deleting .txt files in cache folder fixed.

JamesHeinrich commented 4 years ago

Thanks @mertasan, I had forgotten that there were ImageMagick-related cache files. You don't need to clear the whole cache folder, but if they exist you should delete phpThumbCacheIMcommandlineBase.txt and phpThumbCacheIMversion.txt. @alexmla If that doesn't solve the problem please reopen this issue.