문제

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?


 ?>
도움이 되었습니까?

해결책

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');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top