如何使用imagemagick +命令行字符串+ php压缩图像?

时间:2014-04-10 09:21:18

标签: php imagemagick

如何使用imagemagick +命令行字符串+ php压缩图像?

请看下面的代码:

<?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?


 ?>

1 个答案:

答案 0 :(得分:1)

在Window的命令提示符下,百分比符号需要为escaped。这是因为%字符定义的“Parameter Extensions”功能。要转义它,请使用双倍%%。此外,我认为您要使用-quality,因为-quanlity中未定义exec('convert -strip -quality 75%% 0.jpg 00.jpg');

{{1}}
相关问题