hello,
i hope i can describe my problem. i use the command-line tool identify to get information about some pdf-files. i use the following php-code:
$handle = popen("identify some_file.pdf", "r");
$read = fread($handle, 2048);
pclose($handle);
as a result i only get an error like Error /undefined. and yes, the file exists. but if i a try this command on a shell command line, i get all the information. everything is fine. did i missed something? sorry for my bad english and thanks for your help.
txb
installed versions:
- ImageMagick 6.4.5 2008-11-13 Q16
- php Version 5.2.6
command-line tool identify with popen in php cause problems
Re: command-line tool identify with popen in php cause problems
A PHP or shell environment may be very different from your command line environment. Try using absolute paths. Instead of identify, try /usr/local/bin/identify. Edit delegates.xml and change "gs" to "/usr/local/bin/gs".
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: command-line tool identify with popen in php cause problems
Not sure if this is relevant to your API, but you may need to add 2>&1 to your command in your API. see something similar to what is show in viewtopic.php?f=1&t=13725 for PHP
Re: command-line tool identify with popen in php cause problems
yes, i already tried this. but it's cause the same error. anyway for your answer, thanks.fmw42 wrote:Not sure if this is relevant to your API, but you may need to add 2>&1 to your command in your API. see something similar to what is show in viewtopic.php?f=1&t=13725 for PHP
Re: command-line tool identify with popen in php cause problems
Tried it on my XAMPP server ( php 5.2.9 ) and it works OK and so there must be something wrong with your setup - no idea what it could be though !
As magic says its probably something to do with paths
As magic says its probably something to do with paths
Code: Select all
<?php
$handle = popen("identify 310509.pdf", "r");
$read = fread($handle, 2048);
pclose($handle);
echo $read;
?>
// Output
310509.pdf PDF 595x842 595x842+0+0 16-bit DirectClass 1.433mb
Re: command-line tool identify with popen in php cause problems
thats it! now it works perfectly. thanks a lot.magick wrote:A PHP or shell environment may be very different from your command line environment. Try using absolute paths. Instead of identify, try /usr/local/bin/identify. Edit delegates.xml and change "gs" to "/usr/local/bin/gs".