Reputation: 1413
how to compress image using imagemagick + command line string + php?
please see my codes bellow:
<?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?
?>
Upvotes: 0
Views: 444
Reputation: 24419
The percent symbol will need to be escaped on Window's command prompt. This is because the of "Parameter Extensions" functionality defined by the %
character. To escape it, use double percent %%
. Also, I believe you want to use -quality
, as -quanlity
is not defined in Command-Line Options.
exec('convert -strip -quality 75%% 0.jpg 00.jpg');
Upvotes: 1