Page 1 of 1

why can not i run command line in php?

Posted: 2014-04-10T02:34:48-07:00
by linjuming
why can not i run command line in php?

Code: Select all

<?php 
	/* 
		i want to use comand line to compress image in php
		this code bellow works in cmd but does not works in php
	*/
	
	// in cmd type and run is ok
	// convert -strip -quanlity 75% 0.jpg 00.jpg
	
	// in php does not works
	shell_exec('convert -strip -quanlity 75% 0.jpg 00.jpg');
	// or
	exec('convert -strip -quanlity 75% 0.jpg 00.jpg');
	
	// but this is ok:
	exec('convert -strip 0.jpg 00.jpg');
	
	// why?

	
 ?>

Re: why can not i run command line in php?

Posted: 2014-04-10T03:02:53-07:00
by Bonzo
A couple of things I see:
-quanlity should be -quality
-quality is between 1 and a 100 not 1% and 100%
The image is read in first and so it should be: exec('convert 0.jpg -strip -quality 75 00.jpg');

Re: why can not i run command line in php?

Posted: 2014-04-10T03:08:08-07:00
by linjuming
thank you very much !