2

The command for png optimization plugin Optipng:

The tutorial for using the command

Synopsis: optipng [options] files ... 
Files: Image files of type: PNG, BMP, GIF, PNM or TIFF
Basic options:
  -?, -h, -help show the extended help
  -o optimization level (0-7)    [default: 2]
  -v     run in verbose mode / show copyright and version info
Examples:
   optipng file.png
 (default speed)
   optipng -o5 file.png
 (slow)
   optipng -o7 file.png
 (very slow)
Type "optipng -h" for extended help.

Then I run the following PHP code

$txt = shell_exec("C:\DSPadmin\DEV\optipng\optipng C:\Source\ChangSha\temp_process\production\zoomTxt\A06_text.png");
var_dump ($txt);

return NULL and nothing executed

But when I run the same command in the cmd shell I opened

C:\DSPadmin\DEV\optipng\optipng C:\Source\ChangSha\temp_process\production\zoomTxt\A06_text.png

It work as expected, how to fix the problem ? Thanks

Barmar
  • 741,623
  • 53
  • 500
  • 612
user782104
  • 13,233
  • 55
  • 172
  • 312
  • 1
    is safe mode turned on? Does the user running the web service have permission to run the command and or write to the output directory? – Orangepill Jul 11 '13 at 02:31
  • Did u check in your `php.ini` if this function is not disabled by default? look for `disable_functions` in `php.ini` – Khawer Zeshan Jul 11 '13 at 02:32
  • Thanks for yours help/ The official doc of the plugin: http://optipng.sourceforge.net/optipng-hg.man.pdf , are there any foundings – user782104 Jul 11 '13 at 02:35
  • 1
    Did you enable error reporting and check the error.log; Also use proper escaping for backslashes in double quotes, or the forward slash for paths. – mario Jul 11 '13 at 02:38
  • I tried ini_get('safe_mode') and it returned bool(false) – user782104 Jul 11 '13 at 02:52
  • use popen functions instead and output anything from stderr. There might be valuable information there. The sample on the php help for that function should tell you how to do this. – ToBe Jul 11 '13 at 14:06
  • does the user apache is running as have permission to run optipng ? – exussum Jul 12 '13 at 23:45

1 Answers1

0

Single quote your command.

"\t" in " ...hangSha\temp_proces..." in your string is replaced by the tab character.

bigdot
  • 38
  • 7