I am trying to install ImageMagick for MAMP 4.
My php version is: 7.1.19
I went to applications/MAMP/bin/php/php7.1.12/conf/php.ini
and changed this line ;extension=imagick.so to extension=imagick.so.
I also have a php folder in there of php7.2.1 so I did the above change there too. I restarted MAMP.
After doing that phpinfo told me that ImageMagick is present:
However when I try to run a line of code like this:
header('Content-type: image/jpeg');
$im = new Imagick("test.png");
I received the error localhost is unable to handle this request, if I remove these lines of code then the page loads fine.
I have also installed ImageMagick, imagemagick 7.0.8-14 is already installed and up-to-date.
Related
I'm trying to install imagick on XAMPP x64 with PHP x64 architecture, I followed those steps:
1 - Download and install ImageMagick for Windows, I installed this version: ImageMagick-7.0.9-9-Q16-x64-dll.exe
2 - Download Imagick for PHP, I downloaded this version php_imagick-3.4.4-7.2-ts-vc15-x64, added the php_imagick.dll in xampp/php/ext folder and enabled the extension in php.ini.
3 - Download required Imagick binaries, I downloaded this bin ImageMagick-7.0.7-11-vc15-x64 and added them in xampp/apache/bin folder.
4 - Download Ghostscript, I installed this version gs950w64.
Then I restart XAMPP with all related services. In the phpinfo I see the imagick extension and it works but if I run this code I get an ERR_CONNECTION_RESET error.
$im = new Imagick();
$im->pingImage(realpath('sample.pdf'));
echo $im->getNumberImages();
Here the phpinfo:
What's the problem?
Thanks
UPDATE:
If I run "composer show --platform" I get this warning "PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1799 but version 1801 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0". I don't know if it is relevant.
The problem appears only with PDF files, if I run the same code with a jpg image it works correctly
a bit late, but after a hard day of trying to get Windows + PHP + imagick + Ghostview running I want to share my solution.
Using PHP 7.2 (Tread Safe, WIN 32, CGI/FastCGI) I installed the matching PHP-imagick-version without problems (php_imagick-3.4.4-7.2-ts-vc15-x86.zip)
(Tip for CGI/FastCGI: php_imagick.dll as described into the PHP-ext-directory, but the other 150 imagick-dlls to cgi-bin-folder)
Afterwards I installed the actual win32-version (gs952w32.exe) and got lots of "Internal Server Error" and the apache-error-log growed...:-(
Solution:
Moving backwards in older gs-releases (https://github.com/ArtifexSoftware/ghostpdl-downloads/releases) i succeeded to get a running installation with 9.25 (gs925w32.exe).
BTW:
On my private linux-machine the same installation of PHP, Imagick and Ghostview needed only a few minutes...
Been working for days now trying to find an easy way to install V8Js on XAMPP for windows, yet with no success.
I have downloaded the latest XAMPP version with PHP version 7.2.0 VC15, and followed the instructions in this blog post - https://blog.xenokore.com/how-to-install-v8js-for-php-on-windows/ - but to no avail. I don't see a mention to V8Js in the phpinfo, and when I try to use it I get an ERROR
Error: Class 'V8Js' not found in...
I have downloaded the dll files from here - https://blog.xenokore.com/how-to-install-v8js-for-php-on-windows/ - and used the latest 7.2.1 VC15 x86 ts version with no success.
Can anyone offer some help?
You need to download lasted php version from here instead https://www.apachelounge.com/viewtopic.php?t=6359
Then move a php_v8js.dll from php\ext into same directory on your local.
But with 5 files additional from root directory of php have to move into your apache\bin instead
icui18n.dll
icuuc.dll
v8.dll
v8_libbase.dll
v8_libplatform.dll
Be sure to have it in your php.ini, by adding the following line:
extension=php_v8js.dll
Then try to restart apache or check by command php -m, have fun.
I lost a day trying to figure this out, at various times getting "no decode delegate for this image format" and "The specified module could not be found" errors. The information I could find on these problems was dated in terms of version numbers, and many included instructions like overwriting the ImageMagick-installed dlls from the PECL distribution or copying dlls into windows/system32; two things I didn't want to do.
Environment: Windows 10
Wampserver: 3.0.0, Apache/2.4.17 (Win64) PHP/5.6.16
Downloaded and installed latest ImageMagick:
ImageMagick-7.0.2-0-Q16-x64-dll.exe
Downloaded php_imagick-3.4.3rc1-5.6-ts-vc11-x64 from http://windows.php.net/downloads/pecl/releases/imagick/3.4.3rc1/
Unpacked php_imagick.dll into [wampserver directory]\bin\php\php5.6.16\ext
Added extension=php_imagick.dll to
[wampserver directory]\bin\apache\apache2.4.17\bin\php.ini
Got "no decode delegate for this image format" error, but at least imagick showed up in phpinfo() where I could see that php_imagick.dll was compiled with ImageMagick 6.9.3-7 Q16 x64. There was no obvious way to know this beforehand.
Downloaded ImageMagick-6.9.3-7-Q16-x64-dll.exe from http://ftp.icm.edu.pl/packages/ImageMagick/binaries/ (ImageMagick has removed this package from their site).
Uninstalled ImageMagick-7.0.2-0-Q16-x64,
installed ImageMagick-6.9.3-7-Q16-x64 to c:\ImageMagick,
added c:\ImageMagick to PATH (in front, to avoid collision with windows convert.exe).
Verified everything ok with:
$image = new Imagick();
$image->readImage([path to my jpeg]);
$wm = new Imagick();
$wm->readImage([path to my watermark png]);
$image->compositeImage($wm, imagick::COMPOSITE_OVER, 5, 5);
header("Content-Type: image/jpeg");
echo $image;
I have tried a lot of things. What has done the trick was to add at the end of active php.ini lines :
[ImageMagick]
extension="C:\WampDeveloper\Components\Php\ext\php_imagick\php_imagick.dll"
;imagick.locale_fix=0
;imagick.progress_monitor=0
Credit :
http://www.devside.net/wamp-server/installing-and-using-imagemagick-with-imagick-php-extension-php_imagick-dll-on-wamp
I am on Win Server 2012 IIS 8, PHP 5.6, Imagick Module 3.1.2, ImageMagick 6.8.7-2 2013-10-18 Q16.
I have read through all the Postscript delegate failed errors and have done the following:
- Installed GhostScript
- Checked that GS and Imagick is in the PATH var
- Checked that I can use convert in the command prompt (Does work)
- PHP exec("whoami") returns nt authority\iusr which I added for Full Control
- I tried using full paths backslashes () double-backslashes (\) foward-slashes (/)
- I don't think it has anything to do with the path because if I try the same code on a jpg with no path it works. Script and files are in the same path.
Here is my PHP code:
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
echo exec("whoami"); echo "<br/>";
echo exec("convert.exe dr.pdf dr.jpg 2>&1"); // Does not work and gives below error
echo "<br/>";
$im = new imagick();
$im->readimage("dr.pdf");
$pages = $im->getNumberImages();
echo $pages;
?>
Output:
nt authority\iusr convert.exe: no images defined `dr.jpg' #
error/convert.c/ConvertImageCommand/3145.
Fatal error: Uncaught exception 'ImagickException' with message
'Postscript delegate failed `dr.pdf': No such file or directory #
error/pdf.c/ReadPDFImage/682' in D:\WWW\DEMO\data\temp\test.php:13
Stack trace: #0 D:\WWW\DEMO\data\temp\test.php(13):
Imagick->readimage('dr.pdf') #1 {main} thrown in
D:\WWW\DEMO\data\temp\test.php on line 13
Any help would be greatly appreciated.
Regards
Johan
To anyone who might run into the same problem:
Change the permissions of C:\Windows\Temp to include Full Control for IIS_IUSRS and Users
After I did this everything seems to work!
Note: I had to upgrade to the latest PECL Imagick Module to see the full error that GhostScript was returning, which showed that GhostScript was trying to perform the conversion in windows Temp folder.
It was strange that my php script worked from a command line but not from the website. But obviously it was a permission issue.
I'm posting the following Installation steps for whoever runs into the same problem (Or if I need a guide in the future and I forgot :) )
On Windows 2012 Server with IIS 8
Install Win Platform Installer (https ://www.microsoft.com/web/downloads/platform.aspx)
Go to IIS Manager and open Web Platform Installer and Install PHP 5.6
Download ImageMagick x86 DLL install from here: http://www.imagemagick.org/download/binaries/ImageMagick-6.9.1-9-Q16-x86-dll.exe
Install ImageMagick and ensure that $_SERVER["Path"] has the ImageMagick path configured.
Download the latest PECL ImageMagick x86 NonThreadSafe PHP module here: http://windows.php.net/downloads/pecl/releases/imagick/3.3.0RC2/php_imagick-3.3.0rc2-5.6-nts-vc11-x86.zip
Copy all the PECL ImageMagick DLL files into PHP\ext
Add extension=php_imagick.dll in your php.ini file
Download and Install GhostScript x64 here: http: //downloads.ghostscript.com/public/gs916w64.exe (Not x86 as ImageMagick delegates to the 64bit GhostScript)
Ensure that GhostScript Path is in $_SERVER["Path"] variable (C:\Program Files\gs\gs9.16\bin)
IMPORTANT LAST STEP: Add user rights to C:\Windows\Temp for IIS_USRS and Users
Restart Server (Usually required for PHP to see the paths)
What always helped me is testing my most basic script through a command prompt> php.exe test.php
This will almost always show you errors if you did something wrong with the install or if you need a VC Redist. Where a website query doesn't always show you the startup errors.
I've tried just about everything I've been able to find and so far nothing seems to work.
Regardless of what I install, php always returns "Fatal error: Class 'Imagick' not found."
My system is:
Win7, 64bit
Apache 2.2.21
PHP 5.3.10
PHP Extension Build: API20090626,TS,VC9
I've installed various versions of ImageMagick (6.6.7, 6.7.1, and 6.8.5, both x86 and x64), and used dll's (VC6 and VC9) from http://chernoivan.ru/tools/imagemagick-dlls.html, http://www.sk89q.com/2010/03/vc6-windows-binaries-for-imagick-2-3-0/, and http://valokuva.org/?m=201211.
WAMP shows the extension as being activated (I added extension=php_imagick.dll to my php.ini file)
phpinfo() though never shows anything specific to imagick besides some path variables and the script itself:
<?php
header('Content-type: image/jpeg');
$image = new Imagick('image.jpg');
// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);
echo $image;
?>
always says class not found.
What could the problem at this point be?
Discovered the problem.
ImageMagick (at least from what I can tell) will not work on a x64 installation of php.
Fix was to install a different version of WAMP with a x86 build of php.
Used the dll found here: http://www.peewit.fr/imagick/
With ImageMagick-6.8.1-8-Q16-x64-dll.exe found here: http://image_magick.veidrodis.com/image_magick/binaries/