Windows PHP Imagick not working - php

I am trying for 1 days and this php imagick don't work in windows. It shows
ImageMagick number of supported formats: 0
ImageMagick supported formats no value
First I went to official php website from here
http://windows.php.net/download/
And downloaded VC14 x64 Non Thread Safe (2017-May-09 23:02:49) PHP 7.1.5
I extracted it into C:\ProgramData\php and added it to PATH variable.
And from that directory i renamed php.ini -devlopment to php.ini
And changed line 738 to extension_dir = "ext" so that extensions can be loaded in PHP.
Then php must be working now.
I went to http://windows.php.net/downloads/pecl/releases/imagick/3.4.3/
And downloaded php_imagick-3.4.3-7.1-nts-vc14-x64.zip
And from that zip file i extracted php_imagick.dll into C:\ProgramData\php\ext directory
And also from that zip file I extracted CORE_RL_*.dll into C:\ProgramData\php folder.
And I added extension=php_imagick.dll to php.ini file at line 892
After that i went to http://windows.php.net/downloads/pecl/deps
And downloaded ImageMagick-6.9.3-7-vc14-x64.zip and extracted content of that folder to C:\ProgramData\ImageMagick directory. And I added C:\ProgramData\ImageMagick\bin to my path.
I think I have done all configuration.
But when I create index.php and add phpinfo() function to file in desktop and try to run
php -S localhost:8080
and go to localhost:8080 in web browser it shows
imagick module enabled
imagick module version 3.4.3
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org
Imagick using ImageMagick library version ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org
ImageMagick copyright Copyright (C) 1999-2015 ImageMagick Studio LLC
ImageMagick release date 2016-03-27
ImageMagick number of supported formats: 0
ImageMagick supported formats no value
Clearly it is not working .Where did I make mistake. Imagik is so painful to install :(

Recently I found this solution:
I went to C:\ProgramData\php and deleted CORE_*.dll file which i copied .
I needed to copy that as doing php -v was showing error at that time.
and after immediately deleting and rebooting server it showed
ImageMagick number of supported formats: 234
I don't know what is happening but i am happy it is working
And above steps will work as documentation for other user who are in problem like me :)

Related

Imagick NoDecodeDelegateForThisImageFormat `PDF' # error/constitute.c/ReadImage/509 while reading PDF in WAMP

I have installed Imagick 3.4.4 in my WAMP using the steps defined here: https://newsinfo-blog.blogspot.com/2015/03/install-imagick-on-wamp-server.html
I then use the following code to convert a PDF to a JPEG image:
$im = new Imagick();
$im->setResolution(300,300);
$im->readImage($_SERVER['DOCUMENT_ROOT'] . '/codeigniter/assets/lofthouse.pdf[0]');
$im->setImageFormat('jpeg');
$im->writeImage('thumblofthouse.jpg');
$im->clear();
$im->destroy();
But I am getting the following error message :
An unknown error has occurred Type: ImagickException
Message: NoDecodeDelegateForThisImageFormat `PDF' #
error/constitute.c/ReadImage/509
What am i doing wrong? How can I save the first page of a PDF as an image?
I have noted that when I try :
print_r(Imagick::queryFormats());
the result is an empty array.
EDIT:
These are the steps I have undertaken so far:
Downloaded ImageMagick https://imagemagick.org/script/download.php#windows and installed it via the installer, put it in my D:\software folder.
Downloaded & installed Ghostscript : https://www.ghostscript.com/download/gsdnld.html , placed it in D:\ folder, and ticked the checkbox to generate the fonts.
Copied the php_imagick.dll file to my /ext/ folder
Copied over all the CORE_RL_* files to apache/bin/ folder
Added the root path to the installation directory of ImageMagick in my PATH variables (and put it way above the PHP line)
EDIT2:
I've also done the following steps, although i'm definitely not sure whether these are needed
Created a new system variable called MAGICK_HOME and let it point to the imagemagick root directory.
modified the policy.xml in ImageMagick by adding <policy domain="module" pattern="{PS,PDF,XPS}" rights="read|write"/> in the policymap attribute.
This is what phpinfo() returns:
imagick module enabled
imagick module version 3.4.4
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version ImageMagick 7.0.7-11 Q16 x86 2017-11-23 http://www.imagemagick.org
Imagick using ImageMagick library version ImageMagick 7.0.7-11 Q16 x86 2017-11-23 http://www.imagemagick.org
ImageMagick copyright Copyright (C) 1999-2015 ImageMagick Studio LLC
ImageMagick release date 2017-11-23
ImageMagick number of supported formats: 0
EDIT3: I am able to convert PDF to JPG via the commandline using ImageMagick. After all the steps above, i'm now getting the following error:
Type: ImagickException
Message: no decode delegate for this image format `PDF' # error/constitute.c/ReadImage/509
Same problem for me. Solved.
Check your file extension, be sure to have '.pdf'
Note : in my case ifpdf version is 1.4 or less, a bad or empty extension is not a problem, conversion will work, but for new pdf version i got exception "no delegated...".

Imagick unable to open module file

I'm trying to use Imagick with PHP. I have installed the program, replaced the core dll files, loaded the dll extension with xampp, but now I get this error:
unable to open module file
`C:\Users\sudom\AppData\Local\ImageMagick\IM_MOD_RL_png_.dll': No such
file or directory # warning/module.c/GetMagickModulePath/830
This is the line causing the problem: $image->setImageFormat('png');.
I took a look to the AppData/Local folder, but there's no ImageMagick folder. If I place it there manually, it throws another error.
I use:
ImageMagick-7.0.7-11-Q16-x86-dll
php_imagick-3.4.3-7.1-ts-vc14-x86
Downlod the latest version from here
https://www.imagemagick.org/script/download.php
ImageMagick-7.0.7-12-Q16-x64-dll.exe
or
ImageMagick-7.0.7-12-Q16-x86-dll.exe
install, make sure adding the Imagick folder to the system PATH.
Optionally you can tick legacy utilities (convert, mogrify) during installation. and check in cmd 'magick -version'
c:\convert --version Version: ImageMagick 7.0.7-12 Q16 x64 2017-11-29
http://www.imagemagick.org Copyright: Copyright (C) 1999-2015
ImageMagick Studio LLC License:
http://www.imagemagick.org/script/license.php Visual C++: 180040629
Features: Cipher DPC Modules OpenMP Delegates (built-in): bzlib cairo
flif freetype gslib jng jp2 jpeg lcms lqr openexr pangocairo png ps
raw rsvg tiff webp xml zlib
Download php_imagick.dll from https://pecl.php.net/package/imagick/3.4.3/windows
meets your php version requirments, put in to ext folder of php and add it to php.ini file.
extension=php_imagick.dll
Than, go to http://windows.php.net/downloads/pecl/deps/
find needed version
3/27/2016 5:32 PM 32707238 ImageMagick-6.9.3-7-vc11-x64.zip
3/27/2016 5:33 PM 31517070 ImageMagick-6.9.3-7-vc11-x86.zip
3/27/2016 5:34 PM 38717224 ImageMagick-6.9.3-7-vc14-x64.zip
3/27/2016 5:34 PM 37376244 ImageMagick-6.9.3-7-vc14-x86.zip
download package and put all the DLLs files from ImageMagick-6.9.3-7-vc1x-xxx.zip\bin\ except ImageMagickObject.dll to ...\apache\bin\ and restart the apache service.
MUST WORK!
P.S. You can also find all the stuff from mentioned above resources for PHP 7.2 except pecl library. Need to wait for a while.

Imagemagick tiff installed and working but php Imagick extension supports no tiff

I'm running xampp on macOS (10.12.6) and installed Imagemagick (ImageMagick 7.0.7-3 Q16 x86_64 2017-09-19 ).
With the installed php Imagick extension, I can convert in php images from jpeg to png without problems.
But when I want to convert from tiff to png/jpeg, it doesnt work with the Imagick extension. But it works in terminal and the Imagemagick tiff DELEGATE is supported.
When I look at phpinfo(), there's no tiff support listed.
the PHP error is:
Uncaught ImagickException: unable to load module
'/usr/local/Cellar/imagemagick/7.0.7-3/lib/ImageMagick//modules-Q16HDRI/coders/tiff.la':
file not found # error/module.c/OpenModule/1270
Is the problem the double-backslash in the path?
When I navigate in the finder to the path with doubleback-backslash removed, there is the correct file.
I found the solution among the answers to issue #3919 for Homebrew on GitHub.
Try recompiling php-imagick71 and imagemagick one or several times in different order.
brew reinstall -s php-imagick71
brew reinstall -s imagemagick

php imagick error when pdf involved

When I try to convert the first page of a PDF into JPG through PHP imagick, I get an HTTP 500 error with no log in php_errors.log.
Explanation from IIS: The FastCGI process exited unexpectedly
Error code: 0xc0000417
Two files are created in C:\Windows\Temp, the first one is the PDF read; the other is 0 Kb length.
I am able to perform command line conversions with ImageMagick (convert some.pdf some.jpg). So, ImageMagick and GhostScript are running fine. Also, I am able tho convert between JPG and GIF from PHP scripts.
PHP code:
$im = new Imagick();
$im->setResolution(300,300);
$im->readimage('poster.pdf[0]');
$im->setImageFormat('jpeg');
$im->writeImage('poster.jpg');
$im->clear();
$im->destroy();
My environment:
Windows 7 Professional 64 bit
IIS 7.5
PHP 5.3.6 NTS VC9 via FastCGI
PHP imagick extension v.3.1.2 (5.3 NTS VC9 x86, from PECL)
ImageMagick-6.7.7-0-Q16-windows-dll (x86)
GhostScript 9.07 win32 (x86)
Microsoft Visual C++ 2008 redistributable x86
Path to ImageMagick added to PATH environment variable
Permissions granted to IUSR and IIS_IUSRS in folders C:\Windows\Temp and C:\imagemagick.
So, can anyone give me some guidance to debug this error and have the thing running?
As Danack suggested, ImageMagick MUST be downloaded from the same place imagick was. Compiler version and processor architecture must be respected to match the ones of PHP and GhospScript (in my case, VC9, x86).
Nevertheless, not all versions of ImageMagick availables at this repository appear to be consistent with those of imagick and / or GhostScript. In my case, the combination that finally worked (at second attempt) was:
imagick 3.1.2
ImageMagick 6.8.8
GhostScript 9.07

Unable to work on ImageMagick properly on Windows xampp

I read all the questions before posting this .
I am trying to install ImageMagick on my local system Windows 7.It gets installed without But when i try using it to crop images I get NoDecodeDelegateForThisImageFormat .
I am running Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
This is what i did
I installed ImageMagick ImageMagick-6.8.9-8-Q16-x86-dll.exe (I tried 6.8.1 and 6.7 also)
I got the dll from http://pecl.php.net/package/imagick/3.1.2/windows TS for PHP 5.4
Updated php.ini
The server started with out problem .
I checked via cmd the ImageMagick is working fine.
phpinfo() ImageMagick number of supported formats: 0
I tried many DLL's but none is working i need a solution to this .
Also phpinfo keeps on showing ImageMagick version:ImageMagick 6.8.8-4 Q16 x86 2014-01-29 even when i uninstalled it / updated it .
identify -version
Version: ImageMagick 6.8.9-8 Q16 x86 2014-08-26 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsv
g tiff webp xml zlib
I am trying to open Jpg.
ImageMagick inside php is a really different from the standalone cmd version.
So, you need not only the php_imagic.dll connected to your php.ini.
But also the CORE_RL_*_.dll files in the Apache bin directory.
This will enable the readers.
Now you need the ENcoders. These are obtained from the standalone installation and located in [ImageMagick install dir]\modules\coders. Copy them to Apache's bin directory as well.
Now check the phpinfo();
The downside of this is that you need to match dll's from Standalone version to the one that is Compiled in the php-extension.

Categories