I had installed ImageMagick in XAMPP 1.8.1 come with PHP 5.4.7. I want to have thumb generate in JPG while uploading PDF file. I follow this guide (http://www.elxsy.com/2009/07/installing-imagemagick-on-windows-and-using-with-php-imagick/) to installing the dll and test run the script, but end up I get below error:
Fatal error: Class 'imagick' not found in C:\...
What's wrong come with this installation?
SOLUTION:
I just got it to work by installed ImageMagick 6.8.0. I use the package here: http://valokuva.org/?p=197
set the path in environment variable
First go to the system properties and click on environment variables and give the path of imagemagick library path in PATH variable.
C:\ImageMagick
Related
I've installed ImageMagick, PHP Imagick, Ghostscript on my Windows Server. Everything works fine by cmd prompt and by php exec() function. But it doesn't work via Imagick Class.
This part of code:
$im = new Imagick();
$im->setFormat('PNG');
$im->readImageBlob($this->config->item('system_path')."ftp/MAKRO-INFO/x1.png");
returns ImagickException:
Fatal error: Uncaught exception 'ImagickException' with message 'unable to load module `C:\Windows\system32\config\systemprofile\.magick\IM_MOD_RL_PNG_.dll': An unknown error occurred # error/module.c/OpenModule/1282'
I am very surprised why is Imagick searching for modules in windows/system32/ directory. Of course it doesn't work when access to this path is denied.
My question is, where/how can I change this path (configuration file, registry or enviroment variables)?
This is my phpinfo. As you can see, no modules have been loaded (0 supported formats).
and PATHs:
Found the solution. There was a collision between ImageMagick version and PHP imagick version.
I used these versions:
ImageMagick-6.8.0-3-Q16
php_imagick-3.2.0RC1-5.4-nts-vc9-x86
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.
Im trying to convert a PDF to a png file using MAMP 3.0.5. I know that my PHP code works as it works fine on our Linux server...
I have setup MAMP 3.0.5 on my Mac OSX 10.8.5 and when I run the script to convert the PDF to png file I get the following error:
Fatal error: Uncaught exception 'ImagickException' with message 'Postscript delegate failed `/Applications/MAMP/htdocs/timesheets.com/saas/public_html/timesheets1/timesheets/Daisy_Morris_53635951154c7.pdf': No such file or directory # error/pdf.c/ReadPDFImage/713'<
Please help, this is driving me crazy!
I just found this blog post: http://lamp-ios.com/?p=216
The problem was that MAMP pro's PATH variable doesn't include the path the ghost script, which ImageMagick uses under the hood on PDF manipulation.
The steps to fix it were:
get the path to ghost script by typing "which gs" in the console
in your php:
putenv('PATH=' . getenv('PATH') . ':/opt/local/bin/');
where /opt/local/bin/ is the path to your gs install
This might help. I just ran into the same issue and solved it a few hours later.
My first instinct was to make sure PHP was looking at the right PATH. For me, it was this:
putenv('PATH=' . getenv('PATH') . ':/usr/local/bin');
That didn't seem to help on its own, but I left the code in there because at some point GhostScript is going to need to know where to find those libpng files.
My next step was to examine MAMP's Apache error log. I found this as the probable culprit:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/bin/gs
Reason: Incompatible library version: gs requires version 29.0.0 or later, but libpng16.16.dylib provides version 23.0.0
Very strange, because my libpng in /usr/local/lib is up to date (1.6.12).
After much trial and error, I found that as of 3.0.5, MAMP is overriding with its own libpng files, in /Applications/MAMP/Library/lib
I removed libpng16.16.dylib from /Applications/MAMP/Library/lib, restarted MAMP, tried again, and got this error:
dyld: Library not loaded: /usr/local/lib/libfreetype.6.dylib
Referenced from: /usr/local/bin/gs
Reason: Incompatible library version: gs requires version 18.0.0 or later, but libfreetype.6.dylib provides version 17.0.0
Well that's something different, so I removed libfreetype.6.dylib from /Applications/MAMP/Library/lib as well, and restarted MAMP.
At this point, everything began working. At least for me, the two steps were to make sure PHP's PATH is looking at the right directory, and then to remove the offending files from MAMP's included libpng library, forcing PHP to use the up-to-date libpng files in /usr/local/lib.
I have downloaded and installed Imagick, added it to the system path and successfully tested the installation.
Also, I've downloaded the php_imagick.dll and put it in my php/ext/ folder.
Finally, I added this extension=php_imagick.dll in the php.ini file.
(Following this tutorial)
Running php via localhost gives me the following error (php does not crash):
Fatal error: Class 'Imagick' not found in C:\wamp\www\ ...
When inspecting dependencies of php_imagick.dll with a program called 'Dependency Walker', I see the this.
Tried to fix it (without success) by :
using different versions of Imagick installation
using older php_imagick.dll versions
multiple reboots of the system
relocating dependent dll's (this causes a dependency 'cannot find' chain reaction)
So, I think I'm supposed to look for a dependency location fix, but I haven't found one yet.
You are probably looking for this: http://valokuva.org/
There you will find steps on how to install imagick on windows.
I using code demo from link
http://djpate.com
When I run http://localhost:8080/test/OAuthProviderExample/client/index.php is it get error Fatal error: Class 'Oauth' not found in C:\wamp\www\test\OAuthProviderExample\client\index.php on line 2
in client/index.php i using:
$oauth_client = new Oauth("key","secret"); // line 2
$oauth_client->enableDebug();
How to fix it, i using wampserver in windows 7
remember there's one step in the tutorial:
sudo pecl install oauth
This is installing the oauth lib, in Windows OS it should be "oauth.dll" liked file, check where to get the lib file for Windows. and see if the problem solved.
I had this same problem. I think wamp installs using win32 bits by default. Even if you are running windows 64bit OS. So download the 86x version here For PHP version 5.5 .
Extract the Zip file and copy the php_oauth.dll found in your extract to C:\wamp\bin\php\php5.5.12\ext Click on your wamp server, goto PHP>php.ini, add thisextension=php_oauth.dll to a place where you find similar text or anywhere. Now exit your wamp server. Start it up again and in PHP>PHP extensions you should see php_oauth ticked. However, if you still encounter problems goto PHP error logto get a clue. Cheers!
Oauth for PHP 5.4 Windows x86
PHP/5.4.7
http://zahymaka.com/314/php-5-4-oauth-x86-windows
This is not my source so im not sure how stable ,but it was the only option I've found after about an hour and a half of searching.
Throw the file into your php/ext folder
Edit your php.ini to include the extension
extension=php_oauth.dll