Convert using ImageMagick using PHP
Re: Convert using ImageMagick using PHP
please see last post...
I downloaded Ghostscript GPL 9.07 for Win 64 and installed it: http://www.ghostscript.com/download/gsdnld.html
$array=array();
echo "<pre>";
exec(" C:\inetpub\wwwroot\ImageUpload\ImageMagick-6.8.6-Q16\convert.exe uploads/17364.pdf uploads/thumbs/Test.png 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
Array
(
[0] => convert.exe: Postscript delegate failed `uploads/17364.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/682.
[1] => convert.exe: no images defined `uploads/thumbs/Test.png' @ error/convert.c/ConvertImageCommand/3106.
)
1
DONE
I downloaded Ghostscript GPL 9.07 for Win 64 and installed it: http://www.ghostscript.com/download/gsdnld.html
$array=array();
echo "<pre>";
exec(" C:\inetpub\wwwroot\ImageUpload\ImageMagick-6.8.6-Q16\convert.exe uploads/17364.pdf uploads/thumbs/Test.png 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
Array
(
[0] => convert.exe: Postscript delegate failed `uploads/17364.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/682.
[1] => convert.exe: no images defined `uploads/thumbs/Test.png' @ error/convert.c/ConvertImageCommand/3106.
)
1
DONE
Re: Convert using ImageMagick using PHP
Looks like Ghostscript is installed OK - now at the limit of my knowledge. Hopefuly somebody else will come along soon and offer some more advice.
We both posted at the same time so our posts crossed but I still do not know about this problem.
We both posted at the same time so our posts crossed but I still do not know about this problem.
Re: Convert using ImageMagick using PHP
Can i call the ghostscript .exe directly and bypass ImageMagick?
Re: Convert using ImageMagick using PHP
so confused..anyone know why this might be not working...I can do this with a starting image type of jpg and it works great...but try with PDF and I get the below errors.....uggggg
In the error below:
C:\Program Files\ImageMagick-6.8.6-Q16\modules\coders\IM_MOD_RL_EXE_.dll
Does nto exist in that directory...is this from another install...where shold this be and how to I get it?
In the error below:
C:\Program Files\ImageMagick-6.8.6-Q16\modules\coders\IM_MOD_RL_EXE_.dll
Does nto exist in that directory...is this from another install...where shold this be and how to I get it?
Code: Select all
$dirlist='dir /o/a:-d' ; // DOS directory list command
echo '<b>Initial Directory Listing: </b>' .$dirlist ;
$result = shell_exec($dirlist) ;
echo "<pre>" .$result ."</pre>" ;
$magick_dir = 'C:\inetpub\wwwroot\ImageUpload\ImageMagick' ; // install IM in short DOS 8.3 compatible path
$send_cmd=$magick_dir .'\convert.exe uploads\17364.pdf -resize x100 uploads\thumbs\Test.png' ;
$array=array();
echo "<pre>";
exec("convert.exe $send_cmd 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
echo '<b>Execute command: </b>' .$send_cmd ;
$result = shell_exec($send_cmd) ;
echo "<pre>" .$result ."</pre>" ;
echo '<b>New Directory Listing: </b>' .$dirlist ;
$result = shell_exec($dirlist) ;
echo "<pre>" .$result ."</pre>" ;
Code: Select all
Initial Directory Listing: dir /o/a:-d
Volume in drive C has no label.
Volume Serial Number is 769C-4A3A
Directory of C:\inetpub\wwwroot\ImageUpload
07/11/2013 11:02 AM 1,727 albums.php
07/01/2013 03:25 PM 1,146 create_album.php
07/01/2013 02:18 PM 344 delete_album.php
07/02/2013 11:42 AM 433 delete_image.php
07/01/2013 01:26 PM 1,726 edit_album.php
07/01/2013 07:41 AM 440 index.php
07/02/2013 12:52 PM 957 init.php
06/25/2013 02:05 PM 88 logout.php
06/25/2013 03:22 PM 1,746 register.php
07/11/2013 03:27 PM 2,839 search.php
07/16/2013 12:04 PM 6,088 upload_image.php
07/15/2013 03:16 PM 5,729 view_album.php
12 File(s) 23,263 bytes
0 Dir(s) 141,912,686,592 bytes free
Array
(
[0] => convert.exe: unable to open module file `C:\Program Files\ImageMagick-6.8.6-Q16\modules\coders\IM_MOD_RL_EXE_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/682.
[1] => convert.exe: no decode delegate for this image format `C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert.exe' @ error/constitute.c/ReadImage/552.
[2] => convert.exe: Postscript delegate failed `uploads\17364.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/682.
[3] => convert.exe: no images defined `uploads\thumbs\Test.png' @ error/convert.c/ConvertImageCommand/3106.
)
1
Execute command: C:\inetpub\wwwroot\ImageUpload\ImageMagick\convert.exe uploads\17364.pdf -resize x100 uploads\thumbs\Test.png
New Directory Listing: dir /o/a:-d
Volume in drive C has no label.
Volume Serial Number is 769C-4A3A
Directory of C:\inetpub\wwwroot\ImageUpload
07/11/2013 11:02 AM 1,727 albums.php
07/01/2013 03:25 PM 1,146 create_album.php
07/01/2013 02:18 PM 344 delete_album.php
07/02/2013 11:42 AM 433 delete_image.php
07/01/2013 01:26 PM 1,726 edit_album.php
07/01/2013 07:41 AM 440 index.php
07/02/2013 12:52 PM 957 init.php
06/25/2013 02:05 PM 88 logout.php
06/25/2013 03:22 PM 1,746 register.php
07/11/2013 03:27 PM 2,839 search.php
07/16/2013 12:04 PM 6,088 upload_image.php
07/15/2013 03:16 PM 5,729 view_album.php
12 File(s) 23,263 bytes
0 Dir(s) 141,912,449,024 bytes free
Last edited by jaykappy on 2013-07-16T10:15:14-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert using ImageMagick using PHP
Does the command that converts from a PDF work from the prompt? If not, then that needs correcting. Otherwise, it's a server configuration problem.
snibgo's IM pages: im.snibgo.com
Re: Convert using ImageMagick using PHP
Yes it works from the cmd prompt with simply : convert image.pdf image.jpg
So now we are onto Server configuration...I am testing on IIS....do you have any ideas where I can start? Much appreciated.
So now we are onto Server configuration...I am testing on IIS....do you have any ideas where I can start? Much appreciated.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert using ImageMagick using PHP
Sorry, it's been too many years (decades?) since I used IIS.
Maybe it's worth trying a simple gs command from PHP, something like:
Maybe it's worth trying a simple gs command from PHP, something like:
Code: Select all
"c:\program files\gs\gs9.07\bin\gswin64c" --help
snibgo's IM pages: im.snibgo.com
Re: Convert using ImageMagick using PHP
would I exec that? like this
exec("c:\program files\gs\gs9.07\bin\gswin64c" --help);
I tried this but nothing doing
$array=array();
echo "<pre>";
exec("c:\program files\gs\gs9.07\bin\gswin64c" --help, $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
exec("c:\program files\gs\gs9.07\bin\gswin64c" --help);
I tried this but nothing doing
$array=array();
echo "<pre>";
exec("c:\program files\gs\gs9.07\bin\gswin64c" --help, $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert using ImageMagick using PHP
try
exec("c:\program files\gs\gs9.07\bin\gswin64c --help", $array);
exec("c:\program files\gs\gs9.07\bin\gswin64c --help", $array);
Re: Convert using ImageMagick using PHP
did this...get this...ugggggg
$array=array();
echo "<pre>";
exec("c:\program files\gs\gs9.07\bin\gswin64c --help", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
echo 'DONE';
Array
(
)
1
DONE
EDIT: Tried these as well...same result
exec("c:\Program Files (x86)\gs\gs9.07\bin\gswin32c.exe --help", $array);
exec("c:\Program Files (x86)\gs\gs9.07\bin\gswin32.exe --help", $array);
$array=array();
echo "<pre>";
exec("c:\program files\gs\gs9.07\bin\gswin64c --help", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
echo 'DONE';
Array
(
)
1
DONE
EDIT: Tried these as well...same result
exec("c:\Program Files (x86)\gs\gs9.07\bin\gswin32c.exe --help", $array);
exec("c:\Program Files (x86)\gs\gs9.07\bin\gswin32.exe --help", $array);
Re: Convert using ImageMagick using PHP
I can go to cmd and navigate to there Ghostscript is and run "gswin32 -h" and get a response
EDIT: If I can do this from teh command line for GhostScript and ImageMagick I am close....just dont know why it wont work with IIS and from within my PHP page.....ugggg
what could be stopping it from running or seeing the files?
EDIT: If I can do this from teh command line for GhostScript and ImageMagick I am close....just dont know why it wont work with IIS and from within my PHP page.....ugggg
what could be stopping it from running or seeing the files?
Re: Convert using ImageMagick using PHP
Can you try to uninstall the 64bit version of Ghostscript and just install the 32bit version? I have had users of Magick.NET reporting errors when they had both installed. It might be a bug in ImageMagick.
Re: Convert using ImageMagick using PHP
Should I do the same with Imagemagick.....just install the 32 bit version to coincide with the 32 bit install of GS
right now I have the 64 bit version installed.
I installed the 32bit version of GS and was able to command line gswin32c -h and got a response.
What test shoudl I do inside PHP?
THanks
right now I have the 64 bit version installed.
I installed the 32bit version of GS and was able to command line gswin32c -h and got a response.
What test shoudl I do inside PHP?
THanks
Re: Convert using ImageMagick using PHP
Got this back from another post...going to try this....
How do you reference extension ImageMagick and GhostScript in php.ini file?
To run command like this exec("c:\Program Files (x86)\gs\gs9.07\bin\gswin32 -h") from php script, you would need to configure website to run as administrator. IIS guest user does not have sufficient permission to run.
Here is an article how to install imagemagick and ghostscript
http://gary-greendale.blogspot.com.au/2 ... k-for.html
How do you reference extension ImageMagick and GhostScript in php.ini file?
To run command like this exec("c:\Program Files (x86)\gs\gs9.07\bin\gswin32 -h") from php script, you would need to configure website to run as administrator. IIS guest user does not have sufficient permission to run.
Here is an article how to install imagemagick and ghostscript
http://gary-greendale.blogspot.com.au/2 ... k-for.html
Re: Convert using ImageMagick using PHP
I am still working on getting PHP and the DLL installed and recognized...
1. I go to the website where they say the latest version is and its not named php_imagick.dll its called php_imagick_nts.dll
2. I dowloaded the file to my PHP folder which was on C:\Program Files (x86)\PHP\v5.3\ext (After I downloaded the dll I renamed it to php_imagick.dll)
3. I then went into the php.ini file and added this at the end
[PHP_IMAGICK]
extension=php_imagick.dll
I rebooted my machine.
Went into IIS and clicked on the website folder and opened the PHP Manager and clicked on "Check phpinfo()"
I searched this for an IMAGICK section. and could not find one.
I rebooted 2 more times, still nothing.
I even left the file name the same and added that dll as well...still nothing.
Any thoughts why its nto showing up in the phpinfo()?
From Website Help
Imagick is a PHP extension for ImageMagick. The latest version of this file works fine and can be found at file://bpsnt04/transfer/Setups/ImageMagick/php_imagick.dll.
You can find the latest version at http://valokuva.org/builds/. Be sure to download the x86 / VC9 / non-thread-safe version.
Download the file into the extensions folder for PHP, most likely c:\php\ext. See the php,ini entry extension_dir for the location on your machine.
You must now configure PHP to know about the new extension. Edit php.ini and add or uncomment the PHP_IMAGICK entry.
[PHP_IMAGICK]
extension=php_imagick.dll
1. I go to the website where they say the latest version is and its not named php_imagick.dll its called php_imagick_nts.dll
2. I dowloaded the file to my PHP folder which was on C:\Program Files (x86)\PHP\v5.3\ext (After I downloaded the dll I renamed it to php_imagick.dll)
3. I then went into the php.ini file and added this at the end
[PHP_IMAGICK]
extension=php_imagick.dll
I rebooted my machine.
Went into IIS and clicked on the website folder and opened the PHP Manager and clicked on "Check phpinfo()"
I searched this for an IMAGICK section. and could not find one.
I rebooted 2 more times, still nothing.
I even left the file name the same and added that dll as well...still nothing.
Any thoughts why its nto showing up in the phpinfo()?
From Website Help
Imagick is a PHP extension for ImageMagick. The latest version of this file works fine and can be found at file://bpsnt04/transfer/Setups/ImageMagick/php_imagick.dll.
You can find the latest version at http://valokuva.org/builds/. Be sure to download the x86 / VC9 / non-thread-safe version.
Download the file into the extensions folder for PHP, most likely c:\php\ext. See the php,ini entry extension_dir for the location on your machine.
You must now configure PHP to know about the new extension. Edit php.ini and add or uncomment the PHP_IMAGICK entry.
[PHP_IMAGICK]
extension=php_imagick.dll