Convert using ImageMagick using PHP
Re: Convert using ImageMagick using PHP
Imagick is not very well supported an the latest version is a few years old. You need the correct version to go with the php version and I needs to be compiled by a certain version of whatever it is copiled with. I think you will be digging yourself a bigger hole trying to use than getting exec( ) working.
Re: Convert using ImageMagick using PHP
Not sure what you are getting at....to get exec() working I have to add the php_imagick.dll to PHP in IIS . Can you explain a bit further?Bonzo wrote:Imagick is not very well supported an the latest version is a few years old. You need the correct version to go with the php version and I needs to be compiled by a certain version of whatever it is copiled with. I think you will be digging yourself a bigger hole trying to use than getting exec( ) working.
* and I needs to be compiled by a certain version of whatever it is copiled with
* I think you will be digging yourself a bigger hole trying to use than getting exec( ) working.
I wish someone would have mentioned this 40 posts ago...OK so where I stand now is that I have to find the correct version of the php_imagick.dll to go with the correct version of IMagemagick, a while paying attention to the version of IIS (7.5)
IS THERE anyone out there that is trying this on a 2008 R2 windows server running IIS7.5
GOING TO MAKE A NEW POST FOR THIS VERSION ISSUE
Re: Convert using ImageMagick using PHP
I was able to get IIS to recognize the PHP.dll see this post viewtopic.php?f=2&t=23780
1. Went to this site and found the newer dlls for PHP 5.3 and 5.4 - http://valokuva.org/?p=197
*Downloaded the imagick-php54-php53.tgz. and used winzip to open it...if you use Winzip you can see the Path field of the .tgz file...this tells you which one is for 5.3 and
which is for 5.4
*I only tool the one dll for PHP 5.3 but there are the dlls for 5.4 as well (saved them of course)
2. I DID NOT install the latest version of ImageMagick - I installed this one - ImageMagick-6.8.0-1-Q8-windows-dll.exe
3. Go back ito IIS Manager and click on PHP for that website and then clikc on Check phpinfo() ...
* I can now see the 'imagick' in the php info
I have NOT done anything else for rights, permissions, installations etc....
JUST the above
what else am I missing
Through other posts and info I have heard that I need to:
1. Set Website to run as admin on IIS
2. Give rights to the ImageMagick folder for IUSR
Starting to test I run this:
I get this:
Array
(
[0] => convert.exe: unable to open image `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert': No such file or directory @ error/blob.c/OpenBlob/2638.
[1] => convert.exe: no decode delegate for this image format `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert' @ error/constitute.c/ReadImage/550.
[2] => convert.exe: Postscript delegate failed `uploads\17364.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/679.
[3] => convert.exe: no images defined `uploads\thumbs\Test.png' @ error/convert.c/ConvertImageCommand/3044.
)
1
Array
(
[0] =>
[1] => Path: [built-in]
[2] =>
[3] => Name Value
[4] => -------------------------------------------------------------------------------
[5] => NAME ImageMagick
[6] =>
[7] => Path: configure.xml
[8] =>
[9] => Name Value
[10] => -------------------------------------------------------------------------------
[11] => CC vs10
[12] => COPYRIGHT Copyright (C) 1999-2012 ImageMagick Studio LLC
[13] => DELEGATES bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
[14] => FEATURES OpenMP
[15] => HOST Windows
[16] => LIB_VERSION 0x680
[17] => LIB_VERSION_NUMBER 6,8,0,1
[18] => NAME ImageMagick
[19] => RELEASE_DATE 2012-11-01
[20] => VERSION 6.8.0
[21] => WEBSITE http://www.imagemagick.org
[22] => convert.exe: unable to open image `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert': No such file or directory @ error/blob.c/OpenBlob/2638.
[23] => convert.exe: no decode delegate for this image format `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert' @ error/constitute.c/ReadImage/550.
)
1
1. Went to this site and found the newer dlls for PHP 5.3 and 5.4 - http://valokuva.org/?p=197
*Downloaded the imagick-php54-php53.tgz. and used winzip to open it...if you use Winzip you can see the Path field of the .tgz file...this tells you which one is for 5.3 and
which is for 5.4
*I only tool the one dll for PHP 5.3 but there are the dlls for 5.4 as well (saved them of course)
2. I DID NOT install the latest version of ImageMagick - I installed this one - ImageMagick-6.8.0-1-Q8-windows-dll.exe
3. Go back ito IIS Manager and click on PHP for that website and then clikc on Check phpinfo() ...
* I can now see the 'imagick' in the php info
I have NOT done anything else for rights, permissions, installations etc....
JUST the above
what else am I missing
Through other posts and info I have heard that I need to:
1. Set Website to run as admin on IIS
2. Give rights to the ImageMagick folder for IUSR
Starting to test I run this:
Code: Select all
$magick_dir = 'C:\ImageMagick' ; // install IM in short DOS 8.3 compatible path
$send_cmd=$magick_dir .'\convert uploads\17364.pdf uploads\thumbs\Test.png' ;
$array=array();
echo "<pre>";
exec("convert $send_cmd 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
$magickDir2 = 'C:\ImageMagick';
$send_cmd2=$magickDir2 .'\convert -list configure';
$array=array();
echo "<pre>";
exec("convert $send_cmd2 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
I get this:
Array
(
[0] => convert.exe: unable to open image `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert': No such file or directory @ error/blob.c/OpenBlob/2638.
[1] => convert.exe: no decode delegate for this image format `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert' @ error/constitute.c/ReadImage/550.
[2] => convert.exe: Postscript delegate failed `uploads\17364.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/679.
[3] => convert.exe: no images defined `uploads\thumbs\Test.png' @ error/convert.c/ConvertImageCommand/3044.
)
1
Array
(
[0] =>
[1] => Path: [built-in]
[2] =>
[3] => Name Value
[4] => -------------------------------------------------------------------------------
[5] => NAME ImageMagick
[6] =>
[7] => Path: configure.xml
[8] =>
[9] => Name Value
[10] => -------------------------------------------------------------------------------
[11] => CC vs10
[12] => COPYRIGHT Copyright (C) 1999-2012 ImageMagick Studio LLC
[13] => DELEGATES bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
[14] => FEATURES OpenMP
[15] => HOST Windows
[16] => LIB_VERSION 0x680
[17] => LIB_VERSION_NUMBER 6,8,0,1
[18] => NAME ImageMagick
[19] => RELEASE_DATE 2012-11-01
[20] => VERSION 6.8.0
[21] => WEBSITE http://www.imagemagick.org
[22] => convert.exe: unable to open image `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert': No such file or directory @ error/blob.c/OpenBlob/2638.
[23] => convert.exe: no decode delegate for this image format `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert' @ error/constitute.c/ReadImage/550.
)
1
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert using ImageMagick using PHP
I don't use PHP so I could be wrong, but I think exec() doesn't need libraries; it just executes a command, as if it had been issued from the keyboard.
snibgo's IM pages: im.snibgo.com
Re: Convert using ImageMagick using PHP
Imagick is an API for Imagemagick built into later versions of php. You do not need to install it when using exec( )
As far as I can see you are going backwards now as you had everything working except pdf file conversion?
As far as I can see you are going backwards now as you had everything working except pdf file conversion?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert using ImageMagick using PHP
With respect to converting PDF files with exec(), do you know that IM can see your installed Ghostscript. What does
convert -version
in a proper PHP exec command which is set up to show the text returns show. Does it include gs or gslib?
If it does not show any delegates because your version of IM is too old, then try
convert -list configure
and look at the line starting with DELEGATES.
Perhaps you installed it so that PHP knows it is there but not IM.
convert -version
in a proper PHP exec command which is set up to show the text returns show. Does it include gs or gslib?
If it does not show any delegates because your version of IM is too old, then try
convert -list configure
and look at the line starting with DELEGATES.
Perhaps you installed it so that PHP knows it is there but not IM.
Re: Convert using ImageMagick using PHP
Think I finally got it...was a whirl wind...would be so helpful if there was some documentation out there that gave you the steps and versions that work with each other...
1. Major issues were getting php_imgmagick.dll to be recognized in IIS7.5. THis required downloading the proper build for my PHP version 5.3. Can be found here (5.3 and 5.4)
* Went to this site and found the newer dlls for PHP 5.3 and 5.4 - http://valokuva.org/?p=197
* Downloaded the imagick-php54-php53.tgz. and used winzip to open it...if you use Winzip you can see the Path field of the .tgz file...this tells you which one is for 5.3 and which is for 5.4
* I only took the one dll for PHP 5.3 but there are the dlls for 5.4 as well (saved them of course)
* I placed the dll in the PHP folder...on my mchine here C:\Program Files (x86)\PHP\v5.3\ext
* modified the php.ini file to include: extension=php_imagick_nts.dll
2. I DID NOT install the latest version of ImageMagick - I installed this one - ImageMagick-6.8.0-1-Q8-windows-dll.exe
3. reboot
4. Go back ito IIS Manager and click on PHP for that website and then clikc on Check phpinfo() ...
* I can now see the 'imagick' in the php info
5. I installed GhostScript gs907w32 - http://www.ghostscript.com/download/gsdnld.html
6. I made sure I added the IUSR (machine name/IUSR) permissions ot the ImageMagick and gs folders
Tried for a few days to work directly with ImageMagick with no success...
Then decided to try GhostScript directly...which worked great...
I then tested with this:
My final code looks like this, will remove the array and just run the exec
I truly appreciate all your held and comments...they were greatly appreciated...
I will glance back at these posts for a few days if anyone has questions...
1. Major issues were getting php_imgmagick.dll to be recognized in IIS7.5. THis required downloading the proper build for my PHP version 5.3. Can be found here (5.3 and 5.4)
* Went to this site and found the newer dlls for PHP 5.3 and 5.4 - http://valokuva.org/?p=197
* Downloaded the imagick-php54-php53.tgz. and used winzip to open it...if you use Winzip you can see the Path field of the .tgz file...this tells you which one is for 5.3 and which is for 5.4
* I only took the one dll for PHP 5.3 but there are the dlls for 5.4 as well (saved them of course)
* I placed the dll in the PHP folder...on my mchine here C:\Program Files (x86)\PHP\v5.3\ext
* modified the php.ini file to include: extension=php_imagick_nts.dll
2. I DID NOT install the latest version of ImageMagick - I installed this one - ImageMagick-6.8.0-1-Q8-windows-dll.exe
3. reboot
4. Go back ito IIS Manager and click on PHP for that website and then clikc on Check phpinfo() ...
* I can now see the 'imagick' in the php info
5. I installed GhostScript gs907w32 - http://www.ghostscript.com/download/gsdnld.html
6. I made sure I added the IUSR (machine name/IUSR) permissions ot the ImageMagick and gs folders
Tried for a few days to work directly with ImageMagick with no success...
Then decided to try GhostScript directly...which worked great...
I then tested with this:
Code: Select all
$magickDir3 = 'C:\gs\gs9.07\bin';
$send_cmd3=$magickDir3 .'\gswin32c -h';
$array=array();
echo "<pre>";
exec(" $send_cmd3 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
Code: Select all
$magickDir4 = 'C:\gs\gs9.07\bin';
$inputimage = 'uploads/'.$album_id.'/'.$image_file;
$outputimage = 'uploads/thumbs/'.$image_id.'.png';
$send_cmd4=$magickDir4 .'\gswin32c -dNOPAUSE -sDEVICE=png16m -dFirstPage=1 -dLastPage=1 -sOutputFile='.$outputimage.' -r100x100 -q '.$inputimage.' -c quit';
$array=array();
echo "<pre>";
exec(" $send_cmd4 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
I truly appreciate all your held and comments...they were greatly appreciated...
I will glance back at these posts for a few days if anyone has questions...
-
- Posts: 467
- Joined: 2008-12-21T11:51:10-07:00
Re: Convert using ImageMagick using PHP
ABI of imagick is broken
(see https://bugs.php.net/bug.php?id=65167)
Please report bug on the same forum
(see https://bugs.php.net/bug.php?id=65167)
Please report bug on the same forum