logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: php_imagick problems (Windows, php 7.4.9)
Author
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Fri 11 Sep '20 1:40    Post subject: php_imagick problems (Windows, php 7.4.9) Reply with quote

A few bits of contextual information to start:
Apache 2.4.46 x64
PHP 7.4.9 NTS x64 (using mod_fcgid)
php_imagick 3.4.4 (php_imagick-3.4.4-7.4-nts-vc15-x64.zip) and ImageMagick 7.0.7 (imagemagick-7.0.7-11-vc15-x64.zip) from here:
https://mlocati.github.io/articles/php-windows-imagick.html *NOTE*

Now down to the crux of the issue. imagick doesn't seem to load correctly. If I run a couple of commands in CMD in PHP install folder, then imagick does show up, see below:
Quote:
C:\Core-Servers\PHP>php -i | find "imagick"
imagick
imagick module => enabled
imagick module version => 3.4.4
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.skip_version_check => 0 => 0

C:\Core-Servers\PHP>php -i | find "format"
ImageMagick number of supported formats: => 238
ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPS, DPX, DXT1, DXT5, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FLIF, FPX, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GROUP4, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCREENSHOT, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBP, WMF, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, YCbCr, YCbCrA, YUV

C:\Core-Servers\PHP>php -i | find "imagemagick"
Imagick compiled with ImageMagick version => ImageMagick 7.0.7-11 Q16 x64 2017-11-23 http://www.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 7.0.7-11 Q16 x64 2017-11-23 http://www.imagemagick.org


However if I check a phpinfo(); page on the webserver then imagick/imagemagick is nowhere to be found, and each time I restart my webserver I get the following error in my php error log:
Quote:
PHP Warning: PHP Startup: Unable to load dynamic library 'imagick' (tried: C:/Core-Servers/PHP/ext\imagick (The specified module could not be found.), C:/Core-Servers/PHP/ext\php_imagick.dll (The specified module could not be found.)) in Unknown on line 0


The file "C:/Core-Servers/PHP/ext\php_imagick.dll" definitely exists.

*NOTE* To install, I followed the guide near the bottom of this website, copied the files as instructed and amended configs as instructed. Also I have added the IM install directory to my Windows PATH.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Fri 11 Sep '20 10:08    Post subject: Reply with quote

does php-cgi -i | find "imagick" work?

In php.ini

Code:

display_startup_errors = On


That should give you a visible start up error.
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Fri 11 Sep '20 13:58    Post subject: Reply with quote

James Blond wrote:
does php-cgi -i | find "imagick" work?

That command works fine too, saying imagick is enabled, see output below:
Quote:
C:\Core-Servers\PHP>php-cgi -i | find "imagick"
<h2><a name="module_imagick">imagick</a></h2>
<tr class="h"><th>imagick module</th><th>enabled</th></tr>
<tr><td class="e">imagick module version </td><td class="v">3.4.4 </td></tr>
<tr><td class="e">imagick classes </td><td class="v">Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel </td></tr>
<tr><td class="e">imagick.locale_fix</td><td class="v">0</td><td class="v">0</td></tr>
<tr><td class="e">imagick.progress_monitor</td><td class="v">0</td><td class="v">0</td></tr>
<tr><td class="e">imagick.skip_version_check</td><td class="v">0</td><td class="v">0</td></tr>


Having display_startup_errors set to On seems to not yield any extra information.

Also, as was to be expected, if I try to run the test script from the guide I followed, it gives Error 500, accompanied with this in the PHP Log:
Quote:
[11-Sep-2020 12:57:05 Europe/London] PHP Fatal error: Uncaught Error: Class 'Imagick' not found in C:\Core-Servers\Apache24\htdocs\dale\imagick.php:2
Stack trace:
#0 {main}
thrown in C:\Core-Servers\Apache24\htdocs\dale\imagick.php on line 2
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Tue 15 Sep '20 22:29    Post subject: Reply with quote

I had some issues myself using the NTS version of PHP. You may try the TS version (also via mod_fcgid). It is not really slower.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Wed 16 Sep '20 1:53    Post subject: Reply with quote

Quote:
PHP Startup: Unable to load dynamic library

This is often a sign that the extension or one of its dependencies is Win32/X86 while PHP is x64. Or that one of the dependencies cannot be found.

The imagick extension uses more ways to find the DLL's it needs than only the path. When I compile PHP 7.4 x64 it finds the IM_MOD_RL_*.dll's in C:\Program Files\ImageMagick and subdirs and when I compile PHP 7.4 Win32/x86 it finds those DLL's in C:\Program Files (x86)\ImageMagick and subdirs.

Both installations of ImageMagick are NOT in my path, but the eztension finds them anyway. If you have a 32-bits ImageMagick installed somewhere uninstall it and make sure that all DLL's are deleted. If you have a ImageMagick 6 installed uninstall it as well.

Also make sure you copy all the CORE_RL_*.dll's and IM_MOD_RL_*.dll's to the directory with php.exe.

FWIW: php_imagick.dll loads fine in PHP 7.4.11 RC1 nts x64, running under mod_fcgid. But I am running a newer version of ImageMagick then the precompiled ones from windows.php.net that mlocati uses. See https://www.apachelounge.com/viewtopic.php?t=6359
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Thu 17 Sep '20 2:01    Post subject: Reply with quote

James Blond wrote:
I had some issues myself using the NTS version of PHP. You may try the TS version (also via mod_fcgid). It is not really slower.

I'll give this a try, but at a glance I can't really convince myself this is a fix, though admittedly a workaround is better than it just not working entirely.

Jan-E wrote:
Quote:
PHP Startup: Unable to load dynamic library

This is often a sign that the extension or one of its dependencies is Win32/X86 while PHP is x64. Or that one of the dependencies cannot be found.

I did think that myself because although not with imagick I have ran into this problem with other PHP Extensions before, and I remembered it being a dependency issue. I used a tool called Dependencies from github.com/lucasg and analysed php_imagick.dl at least and all the dependencies were satisfied (bar php.dll but that's just because I was in the wrong directory and of course when it's loaded by the PHP Engine it will of course be satisfied).

Jan-E wrote:
The imagick extension uses more ways to find the DLL's it needs than only the path. When I compile PHP 7.4 x64 it finds the IM_MOD_RL_*.dll's in C:\Program Files\ImageMagick and subdirs and when I compile PHP 7.4 Win32/x86 it finds those DLL's in C:\Program Files (x86)\ImageMagick and subdirs.

Both installations of ImageMagick are NOT in my path, but the eztension finds them anyway. If you have a 32-bits ImageMagick installed somewhere uninstall it and make sure that all DLL's are deleted. If you have a ImageMagick 6 installed uninstall it as well.

Also make sure you copy all the CORE_RL_*.dll's and IM_MOD_RL_*.dll's to the directory with php.exe.

I did wonder that and tried using the ImageMagick installers instead of mlocati's files, but that didn't seem to solve the problem. I only have one installation of ImageMagick which is as specified in my original thread (mlocati's files).

Whilst I admit that the CORE_RL and IM_MOD_RL .dll files are not in the directory with php.exe they are in a directory that is in my PATH and I have verified this.

Jan-E wrote:
FWIW: php_imagick.dll loads fine in PHP 7.4.11 RC1 nts x64, running under mod_fcgid. But I am running a newer version of ImageMagick then the precompiled ones from windows.php.net that mlocati uses. See https://www.apachelounge.com/viewtopic.php?t=6359

I've definitely had a good experience with PHP 7.3.x and php_imagick and ImageMagick (using mlocati's files) previously, and yes just for the sake of clarification I did do a fresh install with the correct versions of all the files. I'll take a look at the further reading provided now.
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Thu 17 Sep '20 2:30    Post subject: Reply with quote

So I have to admit I was in doubt but I decided to move the ImageMagick files to the directory with php.exe - and low and behold it worked. Is there something I am missing about how imagick and imagemagick works?
As a side note, is there any way I can workaround this? I don't like my PHP install folder to be so cluttered.

Quote:
[17-Sep-2020 01:23:58 Europe/London] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1799 but version 1802 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0

Alas I did get the above Warning, and that is using the files from the link that Jan-E provided (https://ci.appveyor.com/project/Jan-E/imagemagick-windows/builds/31561250 & https://windows.php.net/downloads/pecl/releases/imagick/3.4.4/). I assume I need a newer version of php_imagick but I am not sure how to compile it myself, and the rc1 and rc2 files are only up to PHP 7.3 (not that I am sure they would fix the problem anyway).
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Thu 17 Sep '20 4:47    Post subject: Reply with quote

You will have to use either mlocati's php_imagick.dll and the CORE_RL*.dll's and IM_MOD_RL*.dll's or my php_imagick.dll and the CORE_RL*.dll's and IM_MOD_RL*.dll's, that I am linking in https://www.apachelounge.com/viewtopic.php?t=6359

For your PHP 7.4 NTS x64 the php_imagick.dll is in
https://phpdev.toolsforresearch.com/php-7.4.10-nts-Win32-vc15-x64.zip

See https://phpdev.toolsforresearch.com/php-7.4.10-nts-Win32-vc15-x64.htm for the php-cgi -i output.
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Thu 17 Sep '20 14:58    Post subject: Reply with quote

Jan-E wrote:
You will have to use either mlocati's php_imagick.dll and the CORE_RL*.dll's and IM_MOD_RL*.dll's or my php_imagick.dll and the CORE_RL*.dll's and IM_MOD_RL*.dll's, that I am linking in https://www.apachelounge.com/viewtopic.php?t=6359

For your PHP 7.4 NTS x64 the php_imagick.dll is in
https://phpdev.toolsforresearch.com/php-7.4.10-nts-Win32-vc15-x64.zip


Apologies, I had not realised your download package included the extra extensions, I've updated to using your files (both PHP 7.4.10 and ImageMagick 7.0.10).

Everything now seems to be working fine, though I haven't yet tried moving the php_imagick dependencies to another directory (i.e. all the IM_MOD_RL and CORE_RL files).
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Tue 22 Sep '20 16:09    Post subject: Reply with quote

Apparently I managed to jump the gun pretty big time on this one.

Quote:
[22-Sep-2020 15:01:19 Europe/London] PHP Fatal error: Uncaught ImagickException: RegistryKeyLookupFailed `CoderModulesPath' @ error/module.c/GetMagickModulePath/665 in C:\Core-Servers\Apache24\htdocs\dale\imagick.php:4
Stack trace:
#0 C:\Core-Servers\Apache24\htdocs\dale\imagick.php(4): Imagick->setimageformat('png')
#1 {main}
thrown in C:\Core-Servers\Apache24\htdocs\dale\imagick.php on line 4


The above error is from a test script I am using, but I am able to reproduce the same error in IP.Board too. I looked at phpinfo() and whilst it does show imagick loaded I actually noticed it shows 0 compatible formats.

EDIT: Upon reverting to mlocati's files, everything worked correctly, with 238 extensions loaded.
Back to top


Reply to topic   Topic: php_imagick problems (Windows, php 7.4.9) View previous topic :: View next topic
Post new topic   Forum Index -> Other Software